<template>
  <div
    style="background: #f5f5f5; overflow: hidden; position: relative"
    v-loading="loading"
  >
    <div class="applyHeade">
      <span class="back">
        <i
          v-if="http.indexOf('dkaq') == -1 || http.indexOf('xcaq') == -1"
          class="el-icon-arrow-left"
          @click="
            () => {
              this.$router.push('/');
            }
          "
        >
          返回首页
        </i>
      </span>
      <span> 在线报名 </span>
      <el-button class="button" type="primary" @click="login"
        >立即登录</el-button
      >
    </div>
    <div class="applyConter">
      <formItem label="培训大类" :requires="true">
        <field
          @click.native="
            vanClick({
              field_type: 'select',
              field_id: 'gz',
              options: '',
              label: '工种',
            })
          "
          v-model="gz"
          :clear="true"
          :readonly="true"
          :icon="true"
        >
        </field>
      </formItem>
      <template
        v-if="
          http.indexOf('taihua') == -1 ||
          (http.indexOf('taihua') != -1 && formLabelAlign.gz != '学历提升')
        "
      >
        <formItem
          :label="
            item.field_type != 'json' && item.field_type != 'jsonTree'
              ? item.label
              : ''
          "
          :requires="
            item.field_type != 'json' &&
            item.field_type != 'jsonTree' &&
            Boolean(item.selected)
          "
          v-for="item in fromList"
          :key="item.id"
          style="position: relative"
          v-show="item.passShow"
        >
          <div
            v-if="item.hint"
            style="
              color: red;
              line-height: 20px !important;
              background-color: rgba(210, 69, 72, 0.06);
              padding: 5px;
              margin-bottom: 12px;
            "
          >
            {{ item.hint }}
          </div>
          <!-- 输入框及选择框 -->
          <field
            @click.native="vanClick(item)"
            v-model="item.placeholder"
            :clear="true"
            @change="inputChange(item)"
            :readonly="
              item.field_type != 'input' &&
              item.field_type != 'number' &&
              item.field_type != 'textarea'
            "
            :icon="
              item.field_type != 'input' &&
              item.field_type != 'number' &&
              item.field_type != 'textarea'
            "
            :type="
              item.field_type == 'textarea' || item.field_type == 'number'
                ? item.field_type
                : 'text'
            "
            v-if="
              item.field_type == 'input' ||
              item.field_type == 'select' ||
              item.field_type == 'number' ||
              item.field_type == 'textarea'
            "
          >
            <!-- &&photoApply -->
            <template #button v-if="item.label == '身份证号' && photoApply">
              <div
                @click.stop="
                  () => {
                    setOptions = {
                      style: {},
                      clip: 0.63,
                      msgs: [
                        '1. 请拍摄或在相册中选择身份证头像面图片',
                        '2. 证件信息必须无遮挡且清晰不模糊。',
                        '3. 照片请勿上下、左右倒置或翻转；',
                      ],
                      field_id: 'id_card_photo',
                    };
                    showcamera = true;
                  }
                "
                style="
                  padding: 4px 12px;
                  font-size: 14px;
                  background-color: #166aff;
                  color: #fff;
                  margin: -12px 0;
                "
              >
                拍照
              </div>
            </template>
          </field>
          <!-- end -->
          <!-- 身份证-->
          <template v-if="item.field_id == 'id_card'">
            <div
              v-if="item.hint"
              style="
                color: red;
                line-height: 20px !important;
                background-color: rgba(210, 69, 72, 0.06);
                padding: 5px;
                margin-bottom: 12px;
              "
            >
              {{ item.hint }}
            </div>
            <div style="display: flex; align-items: center">
              <div>
                <upload
                  v-show="formLabelAlign['id_card_photo']"
                  action="/admin/MemberApply/upload"
                  accept="image/*"
                  :data="{ field: 'id_card_photo' }"
                  :fileList="item.id_card_photo"
                  :plain="false"
                  @change="upChange($event, 'id_card_photo')"
                  @remove="remove('id_card_photo')"
                  @PictureCard="
                    PictureCard({ ...item, field_id: 'id_card_photo' }, $event)
                  "
                  :ref="'img' + 'id_card_photo'"
                  @PictureEditBack="
                    PictureEditBack(
                      { ...item, field_id: 'id_card_photo' },
                      $event
                    )
                  "
                />
                <div>
                  <div
                    v-show="!formLabelAlign['id_card_photo']"
                    style="
                      display: flex;
                      align-items: center;
                      justify-content: center;
                      width: 148px;
                      height: 148px;
                      border: 1px #ddd dashed;
                      border-radius: 8px;
                      background-color: #fbfdff;
                    "
                  >
                    <div
                      @click.stop="
                        openCorme({ ...item, field_id: 'id_card_photo' })
                      "
                      style="
                        font-size: 14px;
                        background-color: #166aff;
                        color: #fff;
                        width: 58px;
                        height: 32px;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        border-radius: 6px;
                      "
                    >
                      拍照
                    </div>
                  </div>
                  <p style="text-align: center; margin-top: 12px">
                    身份证人像面
                  </p>
                </div>
              </div>
              <div>
                <upload
                  v-show="formLabelAlign['id_card_emblem']"
                  action="/admin/MemberApply/upload"
                  accept="image/*"
                  :data="{ field: 'id_card_emblem' }"
                  :fileList="item.id_card_emblem"
                  :plain="false"
                  @change="upChange($event, 'id_card_emblem')"
                  @remove="remove('id_card_emblem')"
                  @PictureCard="
                    PictureCard({ ...item, field_id: 'id_card_emblem' }, $event)
                  "
                  :ref="'img' + 'id_card_emblem'"
                  :PictureEditBackIf="
                    setting.backgroundPhoto &&
                    (setting.backgroundPhoto == '是' ||
                      setting.backgroundPhoto == '高级') &&
                    'id_card_emblem' == 'photo'
                  "
                  @PictureEditBack="
                    PictureEditBack(
                      { ...item, field_id: 'id_card_emblem' },
                      $event
                    )
                  "
                />
                <div style="margin-left: 18px">
                  <div
                    v-show="!formLabelAlign['id_card_emblem']"
                    style="
                      display: flex;
                      align-items: center;
                      justify-content: center;
                      width: 148px;
                      height: 148px;
                      border: 1px #ddd dashed;
                      border-radius: 8px;
                      background-color: #fbfdff;
                    "
                  >
                    <div
                      @click.stop="
                        openCorme({ ...item, field_id: 'id_card_emblem' })
                      "
                      style="
                        font-size: 14px;
                        background-color: #166aff;
                        color: #fff;
                        width: 58px;
                        height: 32px;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        border-radius: 6px;
                      "
                    >
                      拍照
                    </div>
                  </div>
                  <p style="text-align: center; margin-top: 12px">
                    身份证国徽面
                  </p>
                </div>
              </div>
              <!-- <span style="margin-top: 10px; cursor: pointer; color: blue; display: block" v-if="item.defImg"><span @click="openDefimg(item.defImg)">查看示例图片</span></span> -->
            </div>
          </template>
          <!-- img区域 -->
          <template
            v-if="item.field_type == 'img' && item.field_id != 'id_card'"
          >
            <div style="display: flex; align-items: center">
              <upload
                v-show="formLabelAlign[item.field_id]"
                action="/admin/MemberApply/upload"
                accept="image/*"
                :data="{ field: item.field_id }"
                :fileList="item.fileList"
                :plain="false"
                @change="upChange($event, item.field_id)"
                @remove="remove(item.field_id)"
                @PictureCard="PictureCard(item, $event)"
                :ref="'img' + item.field_id"
                :PictureEditBackIf="
                  setting.backgroundPhoto &&
                  setting.backgroundPhoto == '是' &&
                  item.field_id == 'photo'
                "
                @PictureEditBack="PictureEditBack(item, $event)"
              />
              <div
                v-show="!formLabelAlign[item.field_id]"
                style="
                  display: flex;
                  align-items: center;
                  justify-content: center;
                  width: 148px;
                  height: 148px;
                  border: 1px #ddd dashed;
                  border-radius: 8px;
                  background-color: #fbfdff;
                "
              >
                <div
                  @click.stop="openCorme(item)"
                  style="
                    font-size: 14px;
                    background-color: #166aff;
                    color: #fff;
                    width: 58px;
                    height: 32px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    border-radius: 6px;
                  "
                >
                  拍照
                </div>
              </div>
              <div
                style="
                  display: flex;
                  flex-direction: column;
                  margin-left: 16px;
                  justify-content: center;
                "
              >
                <el-button
                  type="text"
                  v-if="item.others && item.others.appendix"
                  @click="downFuled(item.others.appendix)"
                  style="color: #166aff"
                  >附件下载</el-button
                >
                <span
                  style="
                    margin-top: 10px;
                    cursor: pointer;
                    color: #166aff;
                    display: block;
                  "
                  v-if="item.others && item.others.defImg"
                  ><span @click="openDefimg(item.others.defImg)"
                    >查看示例图片</span
                  ></span
                >
              </div>
            </div>
          </template>
          <!-- 签名 -->
          <template v-if="item.field_type == 'sign'">
            <div
              @click="writeName(item, null)"
              v-if="!formLabelAlign[item.field_id]"
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                width: 100%;
                height: 100px;
                background-color: #f5f5f5;
                font-size: 20px;
                border: 1px solid #ddd;
                border-radius: 6px;
              "
            >
              签名
            </div>
            <img
              v-else
              :src="formLabelAlign[item.field_id]"
              alt=""
              style="
                width: 100%;
                height: 100px;
                background-color: #f5f5f5;
                cursor: pointer;
                border: 1px solid #ddd;
                border-radius: 6px;
              "
              @click="writeName(item, null)"
            />
            <span
              style="
                margin-left: 50px;
                cursor: pointer;
                color: red;
                position: absolute;
                top: -30px;
                right: 0;
              "
              @click="openBookalert(item, item.label)"
              >阅读{{ item.label }}</span
            >
          </template>
          <!-- 签名 -->
          <template v-if="item.field_type == 'autowrite'">
            <div
              @click="
                writeName(
                  item,
                  'DomImg' +
                    (item.field_id == 'edu_photo' ? 'xlcn' : item.field_id)
                )
              "
              v-if="!formLabelAlign[item.field_id]"
              style="
                display: flex;
                justify-content: center;
                align-items: center;
                width: 100%;
                height: 100px;
                background-color: #f5f5f5;
                font-size: 20px;
                border: 1px solid #ddd;
                border-radius: 6px;
              "
            >
              签名
            </div>
            <!-- <el-button type="primary" @click="writeName('cnsx', null)" v-if="!autographPath6">签名</el-button> -->
            <img
              v-else
              :src="formLabelAlign[item.field_id]"
              alt=""
              style="
                width: 100%;
                height: 100px;
                background-color: #f5f5f5;
                cursor: pointer;
                border: 1px solid #ddd;
                border-radius: 6px;
              "
              @click="
                writeName(
                  item,
                  'DomImg' +
                    (item.field_id == 'edu_photo' ? 'xlcn' : item.field_id)
                )
              "
            />
            <span
              style="
                margin-left: 50px;
                cursor: pointer;
                color: red;
                position: absolute;
                top: 4px;
                right: 0;
              "
              @click="openBookalert(item, item.label)"
              >阅读{{ item.label }}</span
            >
          </template>
          <!-- 日期(单一) -->
          <template v-if="item.field_type == 'datetime'">
            <field
              @click.native="vanClickDate(item)"
              v-model="item.placeholder"
              :clear="true"
              :readonly="true"
              :icon="true"
            ></field>
          </template>
          <!-- 日期(范围) -->
          <template v-if="item.field_type == 'datetimeRange'">
            <field
              @click.native="vanClickDate(item, 'start')"
              v-model="item.placeholder[0]"
              :clear="true"
              :readonly="true"
              :icon="true"
            ></field>
            至
            <field
              @click.native="vanClickDate(item, 'end')"
              v-model="item.placeholder[1]"
              @change="inputChange(item)"
              :clear="true"
              :readonly="true"
              :icon="true"
            ></field>
          </template>
          <!-- 下载附件 -->
          <template v-if="item.field_type == 'download'">
            <el-button
              class="button"
              type="primary"
              style="background: #166aff"
              @click="downFuled(item.others.appendix)"
              >下载</el-button
            >
          </template>
          <!-- json -->
          <template v-if="item.field_type == 'json'">
            <!-- v-model="JsonListFrom[it.label]"
                    :label="it.label"
                    v-for="(it, index) in JSON.parse(item.options)"
                    :key="index" -->
            <formItem
              :label="it.label"
              v-for="(it, index) in JSON.parse(item.options)"
              :key="index + 152525"
            >
              <field
                @click.native="vanClick(it, '', item)"
                v-model="JsonListFrom[it.label]"
                :clear="true"
                :readonly="
                  it.field_type != 'input' &&
                  it.field_type != 'number' &&
                  it.field_type != 'textarea'
                "
                :icon="
                  it.field_type != 'input' &&
                  it.field_type != 'number' &&
                  it.field_type != 'textarea'
                "
                :type="
                  it.field_type == 'textarea' || it.field_type == 'number'
                    ? it.field_type
                    : 'text'
                "
                @change="inputChange(it)"
                v-if="
                  it.field_type == 'input' ||
                  it.field_type == 'select' ||
                  it.field_type == 'number'
                "
              >
              </field>
              <template v-if="it.field_type == 'datetime'">
                <field
                  @click.native="vanClickDate(it, '', item)"
                  v-model="JsonListFrom[it.label]"
                  @change="inputChange(it)"
                  :clear="true"
                  :readonly="true"
                  :icon="true"
                ></field>
              </template>
            </formItem>
          </template>
          <!-- extra -->
          <template v-if="item.field_type == 'jsonTree'">
            <formItem
              :label="
                it.field_type != 'json' && it.field_type != 'jsonTree'
                  ? it.label
                  : ''
              "
              :requires="
                it.field_type != 'json' &&
                it.field_type != 'jsonTree' &&
                Boolean(item.selected)
              "
              v-for="(it, index) in JSON.parse(item.options)"
              :key="index + 15854"
              style="position: relative"
            >
              <!-- 输入框及选择框 -->
              <field
                @click.native="vanClick(it)"
                v-model="formLabelAlign[it.field_id]"
                :clear="true"
                :readonly="
                  it.field_type != 'input' &&
                  it.field_type != 'number' &&
                  it.field_type != 'textarea'
                "
                :icon="
                  it.field_type != 'input' &&
                  it.field_type != 'number' &&
                  it.field_type != 'textarea'
                "
                :type="
                  it.field_type == 'number' || item.field_type == 'textarea'
                    ? it.field_type
                    : 'text'
                "
                v-if="
                  it.field_type == 'input' ||
                  it.field_type == 'select' ||
                  it.field_type == 'number' ||
                  item.field_type == 'textarea'
                "
              >
              </field>
              <!-- end -->
              <!--  img区域  -->
              <template
                v-if="it.field_type == 'img' && it.field_id != 'id_card'"
              >
                <div
                  v-if="it.hint"
                  style="
                    color: red;
                    line-height: 20px !important;
                    background-color: rgba(210, 69, 72, 0.06);
                    padding: 5px;
                    margin-bottom: 12px;
                  "
                >
                  {{ it.hint }}
                </div>
                <div style="display: flex; align-items: center">
                  <upload
                    v-show="formLabelAlign[it.field_id]"
                    action="/admin/MemberApply/upload"
                    accept="image/*"
                    :data="{ field: it.field_id }"
                    :fileList="it.fileList"
                    :plain="false"
                    @change="upChange($event, it.field_id)"
                    @remove="remove(it.field_id)"
                    @PictureCard="PictureCard(it, $event)"
                    :ref="'img' + it.field_id"
                    :PictureEditBackIf="
                      setting.backgroundPhoto &&
                      (setting.backgroundPhoto == '是' ||
                        setting.backgroundPhoto == '高级') &&
                      it.field_id == 'photo'
                    "
                    @PictureEditBack="PictureEditBack(it, $event)"
                  />
                  <div
                    v-show="!formLabelAlign[it.field_id]"
                    style="
                      display: flex;
                      align-items: center;
                      justify-content: center;
                      width: 148px;
                      height: 148px;
                      border: 1px #ddd dashed;
                      border-radius: 8px;
                      background-color: #fbfdff;
                    "
                  >
                    <div
                      @click.stop="openCorme(it)"
                      style="
                        font-size: 14px;
                        background-color: #166aff;
                        color: #fff;
                        width: 58px;
                        height: 32px;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        border-radius: 6px;
                      "
                    >
                      拍照
                    </div>
                  </div>
                  <span
                    style="
                      margin-top: 10px;
                      cursor: pointer;
                      color: blue;
                      display: block;
                    "
                    v-if="it.others && it.others.defImg"
                    ><span @click="openDefimg(it.others.defImg)"
                      >查看示例图片</span
                    ></span
                  >
                </div>
              </template>
              <!-- 签名 -->
              <template v-if="it.field_type == 'sign'">
                <div
                  @click="writeName(it, null)"
                  v-if="!formLabelAlign[it.field_id]"
                  style="
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 100%;
                    height: 100px;
                    background-color: #f5f5f5;
                    font-size: 20px;
                    border: 1px solid #ddd;
                    border-radius: 6px;
                  "
                >
                  签名
                </div>
                <img
                  v-else
                  :src="formLabelAlign[it.field_id]"
                  alt=""
                  style="
                    width: 100%;
                    height: 100px;
                    background-color: #f5f5f5;
                    cursor: pointer;
                    border: 1px solid #ddd;
                    border-radius: 6px;
                  "
                  @click="writeName(it, null)"
                />
                <span
                  style="
                    margin-left: 50px;
                    cursor: pointer;
                    color: red;
                    position: absolute;
                    top: 2px;
                    right: 0;
                  "
                  @click="openBookalert(it, it.label)"
                  >阅读{{ it.label }}</span
                >
              </template>
              <!-- 签名 -->
              <template v-if="it.field_type == 'autowrite'">
                <div
                  @click="writeName(it, null)"
                  v-if="!formLabelAlign[it.field_id]"
                  style="
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    width: 100%;
                    height: 100px;
                    background-color: #f5f5f5;
                    font-size: 20px;
                    border: 1px solid #ddd;
                    border-radius: 6px;
                  "
                >
                  签名
                </div>
                <img
                  v-else
                  :src="formLabelAlign[it.field_id]"
                  alt=""
                  style="
                    width: 100%;
                    height: 100px;
                    background-color: #f5f5f5;
                    cursor: pointer;
                    border: 1px solid #ddd;
                    border-radius: 6px;
                  "
                  @click="writeName(it, null)"
                />
                <span
                  style="
                    margin-left: 50px;
                    cursor: pointer;
                    color: red;
                    position: absolute;
                    top: 2px;
                    right: 0;
                  "
                  @click="openBookalert(it, it.label)"
                  >阅读{{ it.label }}</span
                >
              </template>
              <!-- 日期(单一) -->
              <template v-if="it.field_type == 'datetime'">
                <field
                  @click.native="vanClickDate(it)"
                  v-model="it.placeholder"
                  :clear="true"
                  :readonly="true"
                  :icon="true"
                ></field>
              </template>
              <!-- 日期(范围) -->
              <template v-if="it.field_type == 'datetimeRange'">
                <field
                  @click.native="vanClickDate(it, 'start')"
                  v-model="it.placeholder[0]"
                  :clear="true"
                  :readonly="true"
                  :icon="true"
                ></field>
                至
                <field
                  @click.native="vanClickDate(it, 'end')"
                  v-model="it.placeholder[1]"
                  :clear="true"
                  :readonly="true"
                  :icon="true"
                ></field>
              </template>
              <!-- json -->
              <template v-if="it.field_type == 'json'">
                <!-- v-model="JsonListFrom[it.label]"
                        :label="it.label"
                        v-for="(it, index) in JSON.parse(it.options)"
                        :key="index" -->
                <formItem
                  :label="it.label"
                  v-for="(it, index) in JSON.parse(it.options)"
                  :key="index + 152525"
                >
                  <field
                    @click.native="vanClick(it, '', it)"
                    v-model="JsonListFrom[it.label]"
                    :clear="true"
                    :readonly="
                      it.field_type != 'input' &&
                      it.field_type != 'number' &&
                      it.field_type != 'textarea'
                    "
                    :icon="
                      it.field_type != 'input' &&
                      it.field_type != 'number' &&
                      it.field_type != 'textarea'
                    "
                    :type="
                      it.field_type == 'textarea' || it.field_type == 'number'
                        ? it.field_type
                        : 'text'
                    "
                    @change="inputChange(it)"
                    v-if="
                      it.field_type == 'input' ||
                      it.field_type == 'select' ||
                      it.field_type == 'number'
                    "
                  >
                  </field>
                  <template v-if="it.field_type == 'datetime'">
                    <field
                      @click.native="vanClickDate(it, '', it)"
                      v-model="JsonListFrom[it.label]"
                      @change="inputChange(it)"
                      :clear="true"
                      :readonly="true"
                      :icon="true"
                    ></field>
                  </template>
                </formItem>
              </template>
            </formItem>
          </template>
        </formItem>
      </template>
      <template v-else>
        <Taihua ref="taihua" :gz="formLabelAlign.gz"></Taihua>
      </template>
      <formItem
        label="验证码"
        :requires="true"
        v-if="
          platform('hzdpx') ||
          platform('xtaq') ||
          (platform('zcaq') && formLabelAlign.gz == '大培训')
        "
      >
        <field v-model="codeChk" :clear="true" :readonly="false" :icon="false">
          <template #button>
            <div
              v-show="hascodeYes"
              @click.stop="hoveCode"
              style="
                padding: 4px 12px;
                font-size: 14px;
                background-color: #166aff;
                color: #fff;
                margin: -12px 0;
              "
            >
              发送验证码
            </div>
            <div
              v-show="!hascodeYes"
              style="
                height: 100%;
                width: 40px;
                display: flex;
                align-items: center;
                justify-content: center;
                color: #000;
              "
            >
              {{ codeTime }}s
            </div>
          </template>
        </field>
      </formItem>
      <formItem
        label="燃气主管部门"
        :requires="true"
        v-if="
          http.indexOf('bosheng') != -1 &&
          formLabelAlign.gz == '燃气从业人员培训'
        "
      >
        <field
          v-model="deptitle"
          :clear="true"
          :readonly="true"
          :icon="true"
          @click.native="showdepbox = true"
        >
        </field>
        <!--   -->
        <van-popup v-model="showdepbox" position="bottom" style="height: 55vh">
          <van-cascader
            v-model="Cascadervalue"
            style="width: 100%; height: 100%"
            title="请选择部门"
            :options="depList"
            @close="showdepbox = false"
            @finish="depFinish"
            :field-names="{
              text: 'title',
              value: 'id',
            }"
          />
        </van-popup>
      </formItem>
      <div
        class="box_form_title"
        style="margin-top: 10px; margin-bottom: 10px; width: 100%"
      >
        <el-button class="button" type="primary" @click="commit">{{
          platform("lyky") ||
          platform("xtaq") ||
          (platform("zcaq") && formLabelAlign.gz == "大培训")
            ? "提交并登录"
            : "提交"
        }}</el-button>
        <div
          v-if="isJf && !platform('bosheng')"
          style="color: #f00; margin-top: 12px"
        >
          已报名未交费学员,请输入身份证、培训科目等信息进行缴费即可开通培训权限
        </div>
      </div>
    </div>
    <!-- 摄像头 -->
    <mumuCamera
      :show.sync="showcamera"
      @info="chengePhoto"
      @success="imgurl"
      :options="setOptions"
    ></mumuCamera>
    <!-- 裁剪 -->
    <simpleCrop
      :crop-params="cropParams"
      @crop="crop"
      v-if="isShowImgCard"
      @close="closeCallback"
    ></simpleCrop>
    <!-- 签名 -->
    <van-dialog
      v-model="dialogShow"
      show-cancel-button
      @cancel="dialogShow = false"
      :before-close="submit"
    >
      <div slot="title" style="padding: 0 20px">
        <span>签名</span>
        <i
          class="el-icon-refresh"
          style="float: right"
          @click="
            () => {
              if (this.fileNameWirth != '注意事项') {
                this.formLabelAlign[this.fileNameWirth] = '';
              }
              this.formLabelAlign.signature =
                this.formLabelAlign.jkcns ||
                this.formLabelAlign.zjbl ||
                this.formLabelAlign.edu_photo ||
                '';
              this.autographPath = this.formLabelAlign.signature;
              this.$refs.autograph.clear();
              this.formLabelAlign[this.fileNameWirth] = '';
            }
          "
        ></i>
      </div>
      <autograph v-if="dialogShow" ref="autograph"> </autograph>
    </van-dialog>
    <!-- 提示信息 -->
    <van-dialog
      v-model="dialogVisible"
      @cancel="dialogVisible = false"
      title="提示"
      v-if="str"
    >
      <div style="max-height: 70vh; overflow: auto">
        <el-input
          v-model="str"
          type="textarea"
          placeholder="请输入内容"
          :autosize="{ minRows: 2 }"
          resize="none"
          :readonly="true"
        ></el-input>
      </div>
    </van-dialog>
    <!-- 弹出层 -->
    <van-popup
      v-model="showAddress"
      position="bottom"
      style="height: 55vh"
      @close="
        () => {
          this.Cascadervalue = '';
        }
      "
    >
      <template
        v-if="
          formLabelAlign.isShow != 'subject_id' &&
          formLabelAlign.isShow != 'region_id'
        "
      >
        <van-picker
          item-height="55px"
          title="请选择"
          show-toolbar
          :columns="columns"
          @confirm="finshAddress"
          @cancel="showAddress = false"
        />
      </template>
      <template v-if="formLabelAlign.isShow == 'region_id'">
        <van-cascader
          v-model="Cascadervalue"
          style="width: 100%; height: 100%"
          :options="pakeHotl"
          title="请选择工作地点"
          @close="
            () => {
              this.showAddress = false;
              this.Cascadervalue = '';
            }
          "
          :field-names="{
            text: 'region_name',
            value: 'region_id',
            children: 'children',
          }"
          @finish="HotFinish"
          @change="HotChange"
        />
      </template>
      <template v-if="formLabelAlign.isShow == 'subject_id'">
        <van-cascader
          v-model="Cascadervalue"
          style="width: 100%; height: 100%"
          :options="subjectListTree"
          title="请选择培训科目"
          @close="showAddress = false"
          :field-names="{
            text: 'title',
            value: 'id',
            children: 'children',
          }"
          @finish="subChange"
        />
      </template>
    </van-popup>
    <!-- 日期弹出层 -->
    <van-popup v-model="showDate" position="bottom" style="height: 55vh">
      <van-datetime-picker
        v-model="currentDate"
        type="date"
        title="选择年月日"
        :min-date="minDate"
        @confirm="dateAddress"
        @cancel="showDate = false"
      />
    </van-popup>
    <van-popup v-model="showDatestart" position="bottom" style="height: 55vh">
      <van-datetime-picker
        v-model="currentDate"
        type="date"
        title="选择年月日"
        :min-date="minDate"
        @confirm="dateAddressStart"
        @cancel="showDatestart = false"
      />
    </van-popup>
    <van-popup v-model="showDateend" position="bottom" style="height: 55vh">
      <van-datetime-picker
        v-model="currentDate"
        type="date"
        title="选择年月日"
        :min-date="minDate"
        @confirm="dateAddressEnd"
        @cancel="showDateend = false"
      />
    </van-popup>
    <div id="DomImgfwxy" class="DomImg" v-if="platform('lyky')">
      <div class="A4page" style="position: relative">
        <!-- https://lyky.taijieyun.com -->
        <img
          style="width: 100%; height: 100%"
          src="https://lyky.taijieyun.com/storage/userimage/lyky/20230525/3cd77c931cfc25a285611143d8cb66de.png"
        />
        <img
          style="height: 70px; right: 280px; top: 165px; position: absolute"
          :src="autographPath"
          alt=""
        />
      </div>
    </div>
    <div v-if="DOMID == 'DomImgjkcns'">
      <div
        id="DomImgjkcns"
        class="DomImg"
        v-if="
          (!platform('htaq') ||
            (platform('htaq') && formLabelAlign.gz != '特种作业')) &&
          (!platform('sanyuan') ||
            (platform('sanyuan') && formLabelAlign.gz != '特种作业'))
        "
      >
        <div class="A4page">
          <h1>个人健康承诺</h1>
          <div style="margin-top: 80px">
            <p style="text-indent: 50px; font-family: '宋体'">
              本人姓名<u>{{ formLabelAlign.nickname }}</u
              >，身份证号码<u>{{ formLabelAlign.username }}</u
              >，现申请<u>{{ subjectTitle }}</u
              >（作业类别）特种作业操作证。本人身体健康，无妨碍从事相应特种作业的器质性心脏病、癫痫病、美尼尔氏症、眩晕症、癔病、震颤麻痹症、精神病、痴呆症以及其他疾病和生理缺陷。{{
                init.district.includes("云南") ? "本人承诺：" : ""
              }}本人对以上信息的真实性负责，如有隐瞒，相关责任全部由本人承担。
            </p>
            <p
              style="text-indent: 50px; font-family: '宋体'"
              v-if="init.district.includes('云南')"
            >
              特此承诺
            </p>
            <div
              style="
                width: 100%;
                display: flex;
                justify-content: flex-end;
                padding-right: 30px;
                margin-top: 150px;
              "
            >
              <span style="font-size: 30px">承诺人（签字）：</span>
              <img :src="autographPath" style="height: 70px" alt="" />
            </div>
            <div
              style="
                width: 100%;
                display: flex;
                justify-content: flex-end;
                padding-right: 30px;
              "
              v-if="init.district.includes('云南')"
            >
              <p style="font-size: 30px; min-width: 300px">
                电话：{{ formLabelAlign.phone }}
              </p>
            </div>
            <div style="width: 100%; display: flex; justify-content: flex-end">
              <span style="font-size: 30px; padding: 0 30px"
                >{{ new Date().getFullYear() }}年</span
              >
              <span style="font-size: 30px; padding: 0 30px"
                >{{ new Date().getMonth() + 1 }}月</span
              >
              <span style="font-size: 30px; padding: 0 30px"
                >{{ new Date().getDate() }}日</span
              >
            </div>
          </div>
        </div>
      </div>
      <div
        id="DomImgjkcns"
        class="DomImg"
        v-if="platform('htaq') && formLabelAlign.gz == '特种作业'"
      >
        <div class="A4page">
          <h1>特种作业人员健康承诺书</h1>
          <div style="margin-top: 80px">
            <p style="text-indent: 50px; font-family: '宋体'">
              本人姓名
              <u>{{ formLabelAlign.nickname }}</u
              >，身份证号码<u>{{ formLabelAlign.username }} </u>，现申请<u>{{
                subjectTitle
              }}</u
              >特种作业操作证。
            </p>
            <p style="text-indent: 50px; font-family: '宋体'">郑重承诺</p>
            <p style="text-indent: 50px; font-family: '宋体'">
              一、本人身体健康状况良好，并无妨碍从事相应特种作业的器质性心
              脏病、癫痫病、美尼尔氏症、眩晕症、癔病、震颤麻痹症、精神病、痴呆
              症以及其他疾病和生理缺陷，能够适应所申请作业项目工作要求。
            </p>
            <p style="text-indent: 50px; font-family: '宋体'">
              二、本《承诺书》同意向社会公开。若违背承诺约定或者作出虚假承
              诺，愿意接受相应的规定处罚，承担违约责任，并依法承担相应的法律责
              任。违诺行为作为失信信息，归集至公共信用信息平台并公示。
            </p>
            <div
              style="
                width: 100%;
                display: flex;
                justify-content: flex-end;
                padding-right: 30px;
                margin-top: 50px;
              "
            >
              <span style="font-size: 16px">承诺人（签字）：</span>
              <img :src="autographPath" style="height: 70px" alt="" />
            </div>
            <div style="width: 100%; display: flex; justify-content: flex-end">
              <span style="font-size: 16px">承诺日期：</span>
              <span style="font-size: 16px; padding: 0 16px"
                >{{ new Date().getFullYear() }}年</span
              >
              <span style="font-size: 16px; padding: 0 16px"
                >{{ new Date().getMonth() + 1 }}月</span
              >
              <span style="font-size: 16px; padding: 0 16px"
                >{{ new Date().getDate() }}日</span
              >
            </div>
          </div>
        </div>
      </div>
      <div
        id="DomImgjkcns"
        class="DomImg"
        v-if="platform('sanyuan') && formLabelAlign.gz == '特种作业'"
      >
        <div class="A4page">
          <h1>特种作业人员健康承诺书</h1>
          <div style="margin-top: 80px">
            <p style="text-indent: 50px; font-family: '宋体'">
              本人申请<u>{{ subjectTitle }}</u
              >操作考试，身体条件符合特种作
              业人员安全技术培训大纲和考核标准规定的基本条件，矫正视力<u>5.0</u>,
              无妨碍从事<u>{{ subjectTitle }}</u
              >特种作业的器质性心
              脏病、癫痫病、美尼尔氏症、眩晕症、癔病、震颤麻痹症、精神病、
              痴呆症、色盲、色弱以及其他对从事<u>{{ subjectTitle }}</u
              >有妨碍 或有安全隐患的疾病和生理缺陷。本人对个人健康承诺的真实性负
              责。
            </p>

            <div
              style="
                width: 100%;
                display: flex;
                justify-content: flex-end;
                padding-right: 30px;
                margin-top: 50px;
              "
            >
              <span style="font-size: 16px">承诺人：</span>
              <img :src="autographPath" style="height: 70px" alt="" />
            </div>
            <div style="width: 100%; display: flex; justify-content: flex-end">
              <span style="font-size: 16px">时间：</span>
              <span style="font-size: 16px; padding: 0 16px"
                >{{ new Date().getFullYear() }}年</span
              >
              <span style="font-size: 16px; padding: 0 16px"
                >{{ new Date().getMonth() + 1 }}月</span
              >
              <span style="font-size: 16px; padding: 0 16px"
                >{{ new Date().getDate() }}日</span
              >
            </div>
          </div>
        </div>
      </div>
    </div>
    <div id="DomImgxlcn" v-if="DOMID == 'DomImgxlcn'" class="DomImg">
      <div class="A4page">
        <h1>个人学历承诺</h1>
        <div style="margin-top: 80px">
          <p style="text-indent: 50px; font-family: '宋体'">
            本人姓名<u>{{ formLabelAlign.nickname }}</u
            >，身份证号码<u>{{ formLabelAlign.username }}</u
            >，现承诺，本人具有{{
              formLabelAlign.education
            }}学历，以上内容真实有效，如有虚假，本人愿意承担相应责任
          </p>
          <div
            style="
              width: 100%;
              display: flex;
              justify-content: flex-end;
              padding-right: 30px;
              margin-top: 150px;
            "
          >
            <span style="font-size: 30px">承诺人（签字）：</span>
            <img :src="formLabelAlign.edu_photo" style="height: 70px" alt="" />
          </div>
          <div style="width: 100%; display: flex; justify-content: flex-end">
            <span style="font-size: 30px; padding: 0 30px"
              >{{ new Date().getFullYear() }}年</span
            >
            <span style="font-size: 30px; padding: 0 30px"
              >{{ new Date().getMonth() + 1 }}月</span
            >
            <span style="font-size: 30px; padding: 0 30px"
              >{{ new Date().getDate() }}日</span
            >
          </div>
        </div>
      </div>
    </div>
    <div id="DomImgzjbl" v-if="DOMID == 'DomImgzjbl'" class="DomImg">
      <div class="A4page">
        <h1>证件办理费用协议</h1>
        <div style="margin-top: 80px">
          <div>
            <p>甲方:</p>
            <p>乙方:</p>
          </div>
          <div>
            <p>
              一、甲方依据相关规定收取乙方培训、考试、办理及发放证件等费用，并依法对乙方提供相关服务。
            </p>
            <p>
              二、乙方必须按甲方规定时间进行培训、考试及取证，因乙方个人原因及行为不能按时参加培训、考试及无法取证者，甲方不予退费。
            </p>
            <p>三、从报名开始，六个月之内必须考完，否则视为自动放弃。</p>
            <p>四、代办人员需将本协议告知学员本人。</p>
            <p>本人已阅读并同意上述协议内容。</p>
          </div>
          <div
            style="height: 300px; width: 460px"
            v-if="formLabelAlign.id_card_photo"
          >
            <img
              style="width: 100%; height: 100%"
              crossOrigin="Anonymous"
              :src="formLabelAlign.id_card_photo + '?' + new Date().getTime()"
              alt=""
            />
          </div>
          <!--  v-if="formLabelAlign.id_card_emblem" -->
          <div
            style="height: 300px; width: 460px"
            v-if="formLabelAlign.id_card_emblem"
          >
            <img
              style="width: 100%; height: 100%"
              crossOrigin="Anonymous"
              :src="formLabelAlign.id_card_emblem + '?' + new Date().getTime()"
              alt=""
            />
          </div>
          <div
            style="
              width: 100%;
              display: flex;
              justify-content: flex-end;
              padding-right: 30px;
              margin-top: 100px;
            "
          >
            <span style="font-size: 30px">承诺人（签字）：</span>
            <img :src="autographPath" style="height: 70px" alt="" />
          </div>
          <div style="width: 100%; display: flex; justify-content: flex-end">
            <span style="font-size: 30px; padding: 0 30px"
              >{{ new Date().getFullYear() }}年</span
            >
            <span style="font-size: 30px; padding: 0 30px"
              >{{ new Date().getMonth() + 1 }}月</span
            >
            <span style="font-size: 30px; padding: 0 30px"
              >{{ new Date().getDate() }}日</span
            >
          </div>
        </div>
      </div>
    </div>
    <jf ref="jf" :openid="openid"></jf>
    <!-- 微信中打开 -->
    <van-popup v-model="TCshow" :style="{ height: '30%' }">
      <span
        @click="copy"
        style="
          display: flex;
          width: 100%;
          height: 100%;
          justify-content: center;
          align-items: center;
          font-size: 1rem;
          color: #f00;
        "
      >
        点击复制该链接在外部浏览器中打开
      </span>
    </van-popup>
    <!-- 编辑图片背景 -->
    <el-dialog
      title="编辑背景色"
      :visible.sync="showProBack"
      top="20px"
      width="100%"
      v-loading="showProBackLoading"
    >
      <div style="display: flex; flex-direction: column; align-items: center">
        <img :src="backPhoto" alt="" style="height: 350px; width: 250px" />
        <div style="display: flex">
          <p
            style="
              margin: 10px 15px;
              background-color: #fff;
              height: 40px;
              width: 40px;
              display: flex;
              align-items: center;
              justify-content: center;
              border-radius: 50%;
              box-shadow: 0px 2px 6px 0 #aaa;
              cursor: pointer;
            "
            @click="checkBackGround('0')"
          ></p>
          <p
            v-if="!platform('sjhg')"
            style="
              margin: 10px 15px;
              background-color: blue;
              height: 40px;
              width: 40px;
              display: flex;
              align-items: center;
              justify-content: center;
              border-radius: 50%;
              box-shadow: 0px 2px 6px 0 #aaa;
              cursor: pointer;
            "
            @click="checkBackGround('1')"
          ></p>
          <p
            v-if="!platform('sjhg')"
            style="
              margin: 10px 15px;
              background-color: #f00;
              height: 40px;
              width: 40px;
              display: flex;
              align-items: center;
              justify-content: center;
              border-radius: 50%;
              box-shadow: 0px 2px 6px 0 #aaa;
              cursor: pointer;
            "
            @click="checkBackGround('2')"
          ></p>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="commitEditPhtot">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  aliasOCR,
  applyList,
  applyAdd,
  subjectList,
  regionList,
  H5PayList,
  H5Pay,
  getcode,
  getopenid,
  mpo,
  sendcode,
  getapplyInfor,
  axios,
  Department,
} from "@/api/apply.js";
import { mapGetters } from "vuex";
import "vant/lib/cascader/style";
import simpleCrop from "simple-crop/index.vue";
import "simple-crop/template-2.css";
import { dataURLtoFile } from "@/utils/64batatoFile";
import autograph from "@/components/autograph";
import {
  upFile,
  upFileqm,
  isNeedFixPhoto,
  ImgUrltoBase,
} from "@/utils/upFiel.js";
import { download } from "@/api/download.js";
import Taihua from "./components/taihua.vue";
import ImgCutter from "vue-img-cutter";
import { downloadAll } from "@/api/download.js";
import mumuCamera from "./mumuCamera.vue";
import { ImagePreview } from "vant";
// import axios from "axios";
// import'@/styles/mobile.css';

import jf from "./jf.vue";
import {
  setapplyid,
  getapplyid,
  delapplyid,
  setopenId,
  getopenId,
  delopenId,
  setstartInfo,
  delstartInfo,
  getstartInfo,
} from "@/utils/cookie.js";
import lrz from "lrz";
export default {
  components: {
    simpleCrop,
    autograph,
    jf,
    Taihua,
    ImgCutter,
    mumuCamera,
  },
  computed: {
    ...mapGetters(["init", "http"]),
  },
  watch: {
    showdepbox(val) {
      if (val) {
        Department().then((res) => {
          this.depList = res.data;
        });
      }
    },
    gz(val) {
      Object.keys(this.formLabelAlign).map((el) => {
        if (
          this.Arrpass.map((item) => item.field_id).includes(el) ||
          el == "isShow" ||
          el == "options" ||
          el == "gz"
        ) {
        } else {
          this.formLabelAlign[el] = "";
        }
      });
    },
  },
  data() {
    return {
      showdepbox: false,
      depList: [],
      deptitle: "",
      gz: "",
      columns: [],
      options: [],
      setting: {},
      showexType: false,
      minDate: new Date(1950, 0, 1),
      currentDate: new Date(),
      fromList: [],
      formLabelAlign: {
        // gz: "",
        isShow: "",
        options: [],
        extra: { address: "", CNPtype: "" },
      },
      showDate: false,
      showDatestart: false,
      showDateend: false,
      codeChk: "",
      JsonListFrom: {},
      GZList: [],
      qyname: "",
      qylogo: "",
      loading: false,
      fileList: [],
      subjectListTree: [],
      subjectlist: "",
      Arrpass: [], //
      showPicker: false,
      showCascader: false,
      Cascadervalue: "",
      pakeHotl: [],
      titleA: "初培",
      pearit: {},
      isShowImgCard: false,
      showProBack: false, //图片背景色修改弹框
      showProBackLoading: false, //图片背景色修改弹框
      backPhoto: "", //修改之后的url
      backPhotoFile: "", //修改之后的file类型文件
      cropParams: {
        // title: "编辑图片(可以拖动边框改变截取图片大小)", //标题
        src: "", // 裁剪图片地址
        size: {
          // 裁剪尺寸
          width: 390,
          height: 567,
        },
        rotateSlider: true, //是否开启旋转刻度盘
        cropSizePercent: 0.65, //裁剪框显示比例
        borderWidth: 1, //裁剪框边框宽度
        funcBtns: ["close", "crop", "around", "reset"], //功能按钮配置
        borderColor: "#fff", //裁剪框边框颜色
        coverColor: "rgba(0,0,0,0.5)", //裁剪框遮罩颜色
        startAngle: -360, //旋转刻度盘开始角度
        endAngle: 360, //旋转刻度盘结束角度
      },
      dialogShow: false,
      autographPath: "", //签名图片地址
      autographPath1: "", //签名图片地址
      autographPath2: "", //签名图片地址
      autographPath3: "", //签名图片地址
      autographPath4: "", //签名图片地址
      autographPath5: "", //签名图片地址
      autographPath6: "", //签名图片地址
      autographPath7: "", //签名图片地址
      autographPath8: "", //签名图片地址
      dialogVisible: false,
      str: "",
      openid: "",
      subjectTitle: "",
      iframeSrc: "",
      isJf: false, // 是否开启在线缴费
      objinvoice: {}, //发票信息
      hutou: "", //发票户头
      shuihao: "", //发票税号
      FpfileList: { fileList: [], field_id: "image" }, //发票图片表
      JkfileList: { fileList: [], field_id: "jkcns" }, //发票图片表
      Rootloading: false,
      admin_user_id: "",
      depid: "",
      dep: "",
      showBox: false,
      TCshow: false,
      downloadURL: "",
      fileNameWirth: "", //被签名字段
      DOMID: "DomImgJK", //dom id
      hascodeYes: true,
      codeTime: 60,
      timeObj: Object,
      showCompanyType: false,
      showAddress: false,
      typeList: [
        "一般工贸",
        "普货运输",
        "危货运输",
        "汽车维修",
        "驾驶培训",
        "危化品",
      ],
      addressList: [
        "禹会",
        "蚌山",
        "龙子湖",
        "经开",
        "高新",
        "淮上",
        "怀远",
        "固镇",
        "五河",
      ],
      //洛阳机车一般工贸学历开始时间
      xueli_time: new Date(),
      xueli_starttime: "",
      //洛阳机车一般工贸学历结束时间
      xueli_endtime: "",
      //洛阳机车一般工贸工作开始时间
      gongzuo_starttime: "",
      //洛阳机车一般工贸工作结束时间
      gongzuo_endtime: "",
      work_starttime: "",
      work_endtime: "至今",
      arrlist: [],
      iphoneDirection: true, //纵向是 true 横向是 false

      showcamera: false, //相机弹框
      photoApply: false, //身份证扫描
      setOptions: {}, //拍照设置
      canvasdata: "",
      base64: "",
    };
  },
  async created() {
    // console.log(,'5666');https://lyky.taijieyun.com
    // ImgUrltoBase('/img/storage/userimage/lyky/20230523/35e1f152e87a67bac254642ef3eebd2c.png').then(res=>{
    //   this.base64 = res
    //   console.log(this.base64,'6666');
    // })
    // lrz('/img/storage/userimage/lyky/20230523/35e1f152e87a67bac254642ef3eebd2c.png',{quality:0.1}).then(res=>{

    //   console.log(res,'7777');
    //   this.base64 = res.base64
    // })
    // this.init()
    if (this.$route.query.adminid) {
      this.admin_user_id = this.$route.query.adminid;
      this.depid = this.$route.query.depid;
      this.dep = this.$route.query.dep;
      setstartInfo(
        JSON.stringify({
          admin_user_id: this.$route.query.adminid,
          depid: this.$route.query.depid,
          dep: this.$route.query.dep,
          grade: this.$route.query.grade,
        })
      );
    } else {
      this.admin_user_id = "";
      this.depid = "";
      this.dep = "";
      console.log(this.platformAnhui());
      if (this.platformAnhui()) {
        setstartInfo(
          JSON.stringify({
            admin_user_id: "1106",
            depid: 1,
            dep: 1,
          })
        );
        this.admin_user_id = "1106";
        this.depid = "1";
        this.dep = "1";
      } else {
        delstartInfo();
      }
    }
    this.GZList = this.init.selected_gz.split(",");
    if (this.platform("xtaq")) {
      this.GZList = ["大培训"];
    }
    if (this.platform("yali")) {
      this.GZList.map((item, index) => {
        if (item == "一般工贸") {
          this.GZList[index] = "一般行业";
        }
        if (item == "安全管理") {
          this.GZList[index] = "危化品";
        }
      });
    }
    if (this.platform("dkaq") || this.platform("xcaq")) {
      this.GZList.map((item, index) => {
        if (item == "安全管理") {
          this.GZList[index] = "高危安管";
        }
      });
    }
    let setting = JSON.parse(this.init.setting);
    this.setting = JSON.parse(this.init.setting);
    if (this.$route.query.name) {
      this.formLabelAlign.gz = this.$route.query.name;
      window.sessionStorage.setItem("Homegz", this.$route.query.name);
    } else {
      if (
        window.sessionStorage.getItem("Homegz") &&
        window.sessionStorage.getItem("Homegz") != "undefined"
      ) {
        this.formLabelAlign.gz = window.sessionStorage.getItem("Homegz");
      } else {
        this.formLabelAlign.gz = this.GZList[0];
      }
    }
    this.qyname = this.init.alias;
    this.qylogo = this.init.qylogo;
    this.applyListData(this.formLabelAlign.gz);
    this.subject(this.formLabelAlign.gz);
    if (setting.invoice) {
      this.objinvoice = JSON.parse(setting.invoice);
    }
    if (setting.bmSerm) {
      this.str = JSON.parse(JSON.stringify(setting.bmSerm));
      if (!this.platform("bosheng")) {
        this.dialogVisible = true;
      }
      if (
        this.platform("bosheng") &&
        this.formLabelAlign.gz.includes("燃气从业")
      ) {
        this.dialogVisible = true;
      }
      // this.$alert(setting.bmSerm,'提示',{
      //     confirmButtonText: '确定',
      //     callback: () => {
      //     },
      //     showClose:false,
      // })
    }

    if (setting.applyPhoto && setting.applyPhoto == "是") {
      this.photoApply = true;
    } else {
      this.photoApply = false;
    }

    //微信客户端 直接获取openid

    if (getapplyid()) {
      H5PayList({ applyid: getapplyid() }).then((resA) => {
        if (resA.code == 200) {
          if (resA.data != "支付成功") {
            this.$toast.fail(resA.data + ",请联系管理员");
            delapplyid();
          } else {
            this.$toast.success("支付成功,两秒后自动跳转到登录页面");
            delapplyid();
            setTimeout(() => {
              window.open(this.http + "/user", "_self");
            }, 2000);
          }
        } else {
          this.$toast.fail(resA.msg);
          delapplyid();
          done();
        }
      });
    } else {
      if (navigator.userAgent.match(/MicroMessenger/i)) {
        if (!getopenId()) {
          this.Rootloading = true;
          getcode(this.$route.query ? this.$route.query : "").then((res) => {
            // window.open(res.data,'_self')
            if (res.code == 200) {
              // this.iframeSrc=res.data.url
              setopenId(res.data.state);
              window.open(res.data.url, "_self");
            }
          });
        } else {
          this.Rootloading = false;
          getopenid({ state: getopenId() }).then((res) => {
            if (res.code == 200) {
              this.openid = res.data.openid;
              delopenId();
            } else {
              delopenId();
            }
          });
        }
      }
      if (setting.PCwxpay == "是") {
        this.isJf = true;
        if (setting.payType == "H5") {
          if (navigator.userAgent.match(/MicroMessenger/i)) {
            this.$dialog
              .confirm({
                title: "提示",
                message: "培训缴费学员请点击右上角···标识，选择在浏览器中打开",
              })
              .then(() => {})
              .catch(() => {});
          }
        } else {
          if (!navigator.userAgent.match(/MicroMessenger/i)) {
            this.$dialog
              .confirm({
                title: "提示",
                message:
                  "培训缴费学员请复制该链接在微信中打开，" + location.href,
              })
              .then(() => {})
              .catch(() => {});
          } else {
          }
        }
      } else {
        this.isJf = false;
      }
    }
    if (this.formLabelAlign.gz == "特种设备") {
      this.showBox = true;
    } else {
      this.showBox = false;
    }
    // window.addEventListener("onorientationchange" in window ? "orientationchange" : "resize", function() {
    //   if (window.orientation === 180 || window.orientation === 0) {
    //       console.log("竖屏");
    //     } if (window.orientation === 90 || window.orientation === -90 ){
    //       console.log("横屏");
    //     } }, false);
    // window.addEventListener('deviceorientation',this.orientationHandler,false) 重力感应
    // function orientationHandler(event) {
    //      document.getElementById("alpha").innerHTML = event.alpha;
    //      document.getElementById("beta").innerHTML = event.beta;
    //      document.getElementById("gamma").innerHTML = event.gamma;
    //      document.getElementById("heading").innerHTML = event.webkitCompassHeading;
    //      document.getElementById("accuracy").innerHTML = event.webkitCompassAccuracy;
    //  }
    if (this.GZList.includes(this.formLabelAlign.gz)) {
    } else {
      this.formLabelAlign.gz = "";
    }
    this.gz = this.formLabelAlign.gz;
    // setTimeout(()=>{this.gz = this.formLabelAlign.gz
    //   this.$forceUpdate()
    // },1500)
    // this.$set(this,'gz',this.formLabelAlign.gz)
    // this.$forceUpdate()
    this.$nextTick(() => {
      // this.submit('confirm');
      //   let canvas = document.getElementById('canvasfwxy')
      //   let ctx =canvas.getContext('2d')
      //   let img = new Image()
      //   img.src= '/img/storage/userimage/lyky/20230523/35e1f152e87a67bac254642ef3eebd2c.png'
      //   canvas.width = 500
      //   canvas.height = 700
      //   img.onload = function(){
      //     ctx.drawImage(img,0,0,img.width,img.height)
      //     console.log(122222);
      //   }
    });
  },
  methods: {
    // orientationHandler(event) {
    //   if(event.beta<10&&event.beta>-10&&event.gamma<10&&event.gamma>-10){
    //     if(event.alpha<110&&event.alpha>70){
    //       this.iphoneDirection=false
    //     }else{
    //       this.iphoneDirection=true
    //     }
    //   }
    // },
    finshType(val) {
      this.showCompanyType = false;
      this.formLabelAlign.extra.CNPtype = val;
    },
    finshwxType(val) {
      this.showexType = false;
      this.formLabelAlign.extra.企业性质 = val;
    },
    async finshAddress(val) {
      this.showAddress = false;
      if (this.formLabelAlign.isShow == "gz") {
        this.gz = val;
        let value = JSON.parse(JSON.stringify(val));
        if (val == "危化品" || val == "高危安管") {
          value = "安全管理";
        }
        if (val == "一般行业") {
          value = "一般工贸";
        }

        await this.applyListData(value);
        this.subject(value);
      }
      this.fromList.map((item) => {
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder = val;
        }
      });

      // this.$set(this.formLabelAlign,this.formLabelAlign.isShow,val)
      if (
        this.formLabelAlign.extra &&
        Object.keys(this.formLabelAlign.extra).filter(
          (item) => item == this.formLabelAlign.isShow
        )[0]
      ) {
        this.formLabelAlign.extra[
          Object.keys(this.formLabelAlign.extra).filter(
            (item) => item == this.formLabelAlign.isShow
          )[0]
        ] = val;
      }
      if (this.formLabelAlign.isShow) {
        this.formLabelAlign[this.formLabelAlign.isShow] = val;
      }
      this.$forceUpdate();
    },
    dateAddress(val) {
      this.showDate = false;
      let date = new Date(val);
      let time =
        date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
      this.Arrpass.map((item) => {
        if (item.field_id == this.formLabelAlign.isShow) {
          if (item.field_type == "datetime") {
            item.placeholder = time;
            this.formLabelAlign[this.formLabelAlign.isShow] = time;
          }
        }
        if (item.field_type == "json") {
          JSON.parse(item.options).map((it) => {
            if (it.label == this.formLabelAlign.isShow) {
              if (it.field_type == "datetime") {
                // it.placeholder=time
                this.$set(this.JsonListFrom, it.label, time);
                // this.JsonListFrom[it.label]=time
                // this.formLabelAlign[this.formLabelAlign.isShow] = JSON.stringify(this.JsonListFrom);
                // this.formLabelAlign = Object.assign({},this.formLabelAlign)
                // this.$set(this.formLabelAlign,this.formLabelAlign.isShow,time)
                this.$forceUpdate();
              }
            }
          });
        }
      });
      // this.JsonListFrom.map(item=>{
      //   if(item.label==this.formLabelAlign.isShow){
      //     console.log(this.formLabelAlign.isShow);
      //     this.formLabelAlign[this.formLabelAlign.isShow] = JSON.stringify(this.JsonListFrom);
      //   }
      // })
    },
    dateAddressStart(val) {
      this.showDatestart = false;
      let date = new Date(val);
      let time =
        date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
      this.Arrpass.map((item) => {
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder[0] = time;
        }
      });
      if (!this.formLabelAlign[this.formLabelAlign.isShow]) {
        this.formLabelAlign[this.formLabelAlign.isShow] = ["", "至今"];
      }
      this.formLabelAlign[this.formLabelAlign.isShow][0] = time;
      if (
        this.formLabelAlign[this.formLabelAlign.isShow][0] &&
        this.formLabelAlign[this.formLabelAlign.isShow][1]
      ) {
        this.formLabelAlign[this.formLabelAlign.isShow] =
          this.formLabelAlign[this.formLabelAlign.isShow].join(",");
      }
    },
    dateAddressEnd(val) {
      this.showDateend = false;
      let date = new Date(val);
      let time =
        date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
      this.Arrpass.map((item) => {
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder[1] = time;
          this.formLabelAlign[this.formLabelAlign.isShow][1] = time;
          if (
            this.formLabelAlign[this.formLabelAlign.isShow][0] &&
            this.formLabelAlign[this.formLabelAlign.isShow][1]
          ) {
            this.formLabelAlign[this.formLabelAlign.isShow] =
              this.formLabelAlign[this.formLabelAlign.isShow].join(",");
          }
        }
      });
    },
    login() {
      window.open(this.http + "/user", "_self");
    },
    //获取验证码
    hoveCode() {
      if (!this.formLabelAlign.phone) {
        return this.$toast.fail("手机号不能为空");
      }
      this.codeTime = 60;
      this.hascodeYes = false;
      clearInterval(this.timeObj);
      sendcode({
        mobile: this.formLabelAlign.phone,
      }).then((res) => {
        if (res.code == 200) {
          this.$toast.success("验证码发送成功");
          this.timeObj = setInterval(() => {
            if (this.codeTime <= 0) {
              this.hascodeYes = true;
              clearInterval(this.timeObj);
            }
            this.codeTime--;
          }, 1000);
        }
      });
    },
    async applyListData(gz) {
      this.loading = true;
      await applyList({ gz, usage: "apply" }).then((res) => {
        this.loading = false;
        if (res.code == 200) {
          this.fromList = res.data
            .filter((item) => item.label != "工种")
            .filter((item) => item.label != "初复审");
          // res.data.map(item=>{
          //     if(item.field_id!='gz'){
          //         this.formLabelAlign[item.field_id]=item.placeholder
          //     }
          // })
          this.fromList.map((item) => {
            if (
              this.formLabelAlign.gz == "一般工贸" &&
              item.label == "职称" &&
              this.platform("saite")
            ) {
              item.options =
                '[{"e":"高级"},{"e":"中级"},{"e":"初级"},{"e":"无"}]';
            }
            if (this.platformAnhui()) {
              if (item.field_id == "photo") {
                item.label = "大头照";
              }
            }
          });

          JSON.parse(JSON.stringify(this.fromList))
            .filter((item) => item.field_type == "json")
            .map((item) => {
              if (item.field_id != "extra") {
                JSON.parse(item.options).map((it) => {
                  this.JsonListFrom[it.label];
                });
              }
            });
          // res.data.map((item) => {
          //   item.passShow = true;
          // });
          res.data.map((item) => {
            item.passShow = true;
            // this.formLabelAlign.isShow = item.field_id;

            if (item.field_type == "datetimeRange") {
              item.placeholder = ["", "至今"];
            }
            if (item.field_id != "gz" && item.field_id != "extra") {
              this.formLabelAlign[item.field_id] = item.placeholder;
            }
            if (item.field_type == "img") {
              this.formLabelAlign[item.field_id] = "";
              this.$forceUpdate();
            }
            if (item.field_id == "extra") {
              Object.assign(this.formLabelAlign, { extra: {} });
              JSON.parse(item.options).map((el) => {
                Object.assign(this.formLabelAlign.extra, {
                  [el.field_id]: el.placeholder,
                });
              });
            }
            if (gz == "特种作业") {
              if (item.label == "现持证书信息") {
                item.passShow = false;
              }
            }
            if (gz == "一般工贸") {
              if (item.label == "安全合格证证号" || item.label == "截止日期") {
                item.passShow = false;
              }
            }
            if (gz == "职业卫生") {
              if (this.platform("ataq")) {
                if (item.field_id == "training_record") {
                  item.passShow = false;
                }
              }
            }
          });
          // Object.assign(this.formLabelAlign, { isShow: "input", options: [] });
          if (this.http.indexOf("zaah") != -1) {
            this.formLabelAlign.subject_id = this.$route.query.id;
          }
          this.Arrpass = res.data;
        }
      });
    },
    // 部门
    depFinish({ selectedOptions }) {
      this.showdepbox = false;
      this.deptitle = selectedOptions.map((option) => option.title).join("/");
      this.formLabelAlign["dep"] = selectedOptions.map((option) => option.id)[
        selectedOptions.map((option) => option.id).length - 1
      ];
      this.formLabelAlign["depid"] = selectedOptions.map((option) => option.id)[
        selectedOptions.map((option) => option.id).length - 1
      ];
    },
    //切换工种
    gzChange(str) {
      let value = str;
      if (str == "危化品" || str == "高危安管") {
        value = "安全管理";
      }
      if (str == "一般行业") {
        value = "一般工贸";
      }
      this.fromList = [];
      this.formLabelAlign = { gz: value };
      this.applyListData(value);
      this.subject(value);
      if (value == "特种设备") {
        this.showBox = true;
      } else {
        this.showBox = false;
      }
    },
    //init
    // async init(){
    //    await applyInit().then( res=>{
    //         if(res.code==200){
    //             console.log(res)
    //             this.GZList=res.data.selected_gz.split(',')
    //             this.qyname=res.data.alias
    //             this.formLabelAlign.gz=this.GZList[0]
    //             this.applyListData(this.GZList[0])
    //             this.subject(this.GZList[0])
    //         }
    //     })
    // },
    //科目
    subject(gz) {
      subjectList(gz).then((res) => {
        this.subjectListTree = res;
        if (this.platform("xtaq") || this.platform("zcaq")) {
          this.subjectListTree = res.filter((item) => {
            return item.id == 794;
          });
        }
        if (this.platform("hshd") && (gz == "特种作业" || gz == "安全管理")) {
          var lop = function (list = []) {
            for (let index = 0; index < list.length; index++) {
              const item = list[index];
              if (item.title == "初培") {
                // item.disabled=true
                list.splice(index, 1);
              } else {
                lop(item.children);
              }
            }
          };
          lop(this.subjectListTree);
        }
        // if (this.platform("xinhua") && gz == "安全管理") {
        //   this.subjectListTree = res.filter((item) => {
        //     return (
        //       item.title == "烟花爆竹生产单位" ||
        //       item.title == "烟花爆竹经营单位"
        //     );
        //   });
        // }
      });
    },
    //科目切换
    subChange(value) {
      let selected = [];
      let selectedOptions = value.selectedOptions;
      this.showAddress = false;
      let subject = [];
      selectedOptions.map((item) => {
        subject.push(item.title);
      });
      value.selectedOptions.map((item) => {
        selected.push(item.id);
      });
      if (selectedOptions.length == 3) {
        this.subjectTitle = selectedOptions[1].title;
      } else {
        this.subjectTitle = selectedOptions[0].title;
      }
      // .indexOf('危险化学品生产单位')

      this.formLabelAlign.subject_id = value.value;
      this.formLabelAlign.subject_ids = selected.join(",");
      this.titleA = selectedOptions[selectedOptions.length - 1].title;
      this.itemA = selectedOptions[selectedOptions.length - 1];

      if (
        selectedOptions[selectedOptions.length - 1].title.indexOf("初培") !=
          -1 ||
        selectedOptions[selectedOptions.length - 1].title.indexOf("复审") != -1
      ) {
        this.formLabelAlign.exam_type =
          selectedOptions[selectedOptions.length - 1].title;
      } else {
        this.formLabelAlign.exam_type = "初审";
      }
      // this.$forceUpdate();
      let gz = this.formLabelAlign.gz;
      // this.Arrpass.map((item) => {

      // });
      this.fromList.map((item) => {
        item.passShow = true;
        if (item.field_id == "last_cert") {
          if (this.titleA.indexOf("初培") != -1) {
            item.passShow = false;
          } else {
            item.passShow = true;
          }
        }
        if (gz == "特种作业") {
          if (this.platformAnhui() || this.platform("qiye")) {
            if (item.field_id == "last_cert") {
              if (this.titleA.indexOf("初培") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
            if (item.field_id == "qzsj") {
              if (this.titleA.indexOf("初培") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
          } else if(!this.platform("lyjc"))  {
            if (item.label == "现持证书信息") {
              if (this.formLabelAlign.exam_type.indexOf("初培") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
            if (item.label == "户口本" || item.label == "毕业证") {
              if (this.formLabelAlign.exam_type.indexOf("复审") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
          }
        }
        if (gz == "一般工贸") {
          if (this.platformAnhui()) {
            if (item.field_id == "last_cert") {
              //初培证书
              if (this.titleA.indexOf("初培") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
            if (item.field_id == "qzsj") {
              if (this.titleA.indexOf("初培") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
          } else {
            if (item.label == "安全合格证证号" || item.label == "截止日期") {
              if (this.titleA.indexOf("初培") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
          }
        }
        if (gz == "安全管理" || gz == "高危安管") {
          if (this.platformAnhui()) {
            if (item.field_id == "zhicheng") {
              if (subject.indexOf("危险化学品生产单位") != -1) {
                item.passShow = true;
              } else {
                item.passShow = false;
              }
            }
            if (item.field_id == "edu_photo") {
              if (subject.indexOf("危险化学品生产单位") != -1) {
                item.hint =
                  "毕业证和职称证选一个进行上传，须化工专业大专或中级职称以上证书";
              } else {
                item.hint = "毕业证和户口本选一个进行上传";
              }
            }
          }
          if (item.field_id == "qzsj") {
            if (this.titleA.indexOf("初培") != -1) {
              item.passShow = false;
            } else {
              item.passShow = true;
            }
          }
        }
        if (gz == "职业卫生") {
          if (this.platform("ataq")) {
            if (item.field_id == "training_record") {
              if (this.titleA.indexOf("初培") != -1) {
                item.passShow = false;
              } else {
                item.passShow = true;
              }
            }
          }
        }
        if (this.platform("yuhua")) {
          if (item.field_id == "edu_photo") {
            if (this.titleA.indexOf("复审") != -1) {
              item.passShow = false;
            } else {
              item.passShow = true;
            }
          }
        }
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder = selectedOptions
            .map((option) => option.title)
            .join("/");
        }
      });
      // this.fromList = this.Arrpass
      this.$forceUpdate();
    },
    //图片编辑
    PictureCard(item, file) {
      this.pearit = item;
      this.isShowImgCard = true;
      // this.cropParams.src = '/imgurl/'+ file.url.split('https://tjy.taijieyun.com/')[1];
      this.cropParams.src = file.url;
    },
    //剪辑图片
    crop(data) {
      this.isShowImgCard = false;
      this.asrsc = data.toDataURL();
      let file = dataURLtoFile(data.toDataURL());
      this.pearit.fileList = [
        {
          url: data.toDataURL(),
          name: "",
        },
      ];
      let srt = "img" + this.pearit.field_id;
      if (this.$refs[srt][0]) {
        this.$refs[srt][0].uploadImg(file);
      } else {
        this.$refs[srt].uploadImg(file);
      }
      // console.log()
    },
    //关闭剪辑
    closeCallback() {
      this.isShowImgCard = false;
    },
    HotChange(value) {
      let id = value.value;
      if (id > 9999) {
        this.deep(this.pakeHotl, id, null);
        return;
      }
      regionList({ region_pid: id }).then((res) => {
        if (res.data.list.length != 0) {
          this.deep(this.pakeHotl, id, res.data.list);
        }
      });
    },
    deep(list = [], id, children = []) {
      for (let i = 0; i < list.length; i++) {
        let item = list[i];
        if (item.region_id == id) {
          item.children = children;
          break;
        } else {
          this.deep(item.children, id, children);
        }
      }
    },
    // cutDown(event) {
    //   console.log(event)
    // },
    //input输入框 改变时触发
    inputChange(value) {
      if (value.field_id == "region_id") return false;
      if (value.field_type != "json") {
        this.formLabelAlign[this.formLabelAlign.isShow] = value.placeholder;
        if (value.field_type == "datetimeRange" && !value.placeholder[1]) {
          value.placeholder[1] = "至今";
        }
      } else {
        this.formLabelAlign[value.field_id] = JSON.stringify(this.JsonListFrom);
      }
      // if(txt=="dep"){
      //     this.formLabelAlign[data.field_id] = data.placeholder.join(',')
      // }
    },
    //上传照片时 触发
    upChange(file, label) {
      if (
        label == "photo" &&
        file.size > 102400 &&
        this.http.indexOf("暂无企业") != -1
      ) {
        // 证件照小于100k
        // this.sefelfs=label
        this.$refs["img" + label][0].handleRemove();
        this.$toast.fail("上传照片不能大于100K!");
      } else {
        if (file.status == "ready") {
          // console.log(this.iphoneDirection,'6666');
          // isNeedFixPhoto(file.raw).then(res=>{
          //   console.log(res,'6666');
          // }).catch(err=>{
          //   console.log(err,'8888');
          // })
          this.arrlist = [];
          this.$refs["img" + label][0].commitUpload();
        }
      }
      if (file.status == "success" && file.response.code == 200) {
        // window.removeEventListener('deviceorientation',this.orientationHandler,false)
        if (label == "last_cert") {
          this.arrlist.push(file.response.data.url);
          this.formLabelAlign.last_cert = JSON.stringify(this.arrlist);
        } else {
          this.formLabelAlign[file.response.data.field] =
            file.response.data.url;
        }
        this.$toast.success(file.response.msg);
        // if (file.response.data.field == "hukou_photo") {
        //   this.Arrpass.map((item) => {
        //     if (item.field_id == "edu_photo") {
        //       item.selected = 0;
        //     }
        //   });
        // } else {
        //   this.Arrpass.map((item) => {
        //     if (item.field_id == "edu_photo") {
        //       item.selected = 1;
        //     }
        //   });
        // }
        // if (file.response.data.field == "edu_photo") {
        //   this.Arrpass.map((item) => {
        //     if (item.field_id == "hukou_photo") {
        //       item.selected = 0;
        //     }
        //   });
        // } else {
        //   this.Arrpass.map((item) => {
        //     if (item.field_id == "hukou_photo") {
        //       item.selected = 1;
        //     }
        //   });
        // }
      } else if (file.status == "success" && file.response.code != 200) {
        // window.removeEventListener('deviceorientation',this.orientationHandler,false)
        this.$toast.fail(file.response.msg);
      }
      this.$forceUpdate();
    },
    //删除照片时 触发
    remove(id) {
      this.formLabelAlign[id] = "";
      this.$forceUpdate();
    },
    //提交
    commit() {
      if (
        this.http.indexOf("taihua") == -1 ||
        (this.http.indexOf("taihua") != -1 &&
          this.formLabelAlign.gz != "学历提升")
      ) {
      } else {
        return this.commitA(); //太化
      }
      // console.log(this.$toCode('372924199607068671'),'加密')
      // console.log(this.$fromCode(this.$toCode('372924199607068671')),'解密')2555
      let formLabelAlign = {};
      console.log(this.formLabelAlign, this.fromList);

      // return
      let a = JSON.parse(JSON.stringify(this.formLabelAlign));
      Object.keys(a).map((item) => {
        this.fromList.map((el) => {
          if (el.field_id == item) {
            formLabelAlign[item] = a[item];
          }
          if (item == "id_card") {
            formLabelAlign["id_card_emblem"] = a["id_card_emblem"]
              ? a["id_card_emblem"]
              : "";
            formLabelAlign["id_card_photo"] = a["id_card_photo"]
              ? a["id_card_photo"]
              : "";
            delete formLabelAlign[item];
          }
        });
      });
      formLabelAlign.subject_ids = a.subject_ids ? a.subject_ids : "";
      formLabelAlign.subject_id = a.subject_ids
        ? a.subject_ids.split(",")[a.subject_ids.split(",").length - 1]
        : "";
      formLabelAlign.gz = a.gz;
      formLabelAlign.dep = a.dep;
      formLabelAlign.signature = a.signature;
      // return;
      // if (
      //   this.http.indexOf("lyjc") != -1 &&
      //   this.formLabelAlign.gz == "特种作业"
      // ) {
      //   formLabelAlign.edu_period = JSON.stringify([
      //     this.xueli_starttime,
      //     this.xueli_endtime,
      //   ]);
      //   formLabelAlign.history = JSON.stringify([
      //     this.work_starttime,
      //     this.work_endtime,
      //   ]);
      //   if (this.xueli_starttime == "") {
      //     this.$message.warning("学历开始时间不能为空");
      //     return;
      //   } else if (this.xueli_endtime == "") {
      //     this.$message.warning("学历结束时间不能为空");
      //     return;
      //   } else if (this.work_starttime == "") {
      //     this.$message.warning("工作开始时间不能为空");
      //     return;
      //   } else if (this.work_endtime == "") {
      //     this.$message.warning("工作结束时间不能为空");
      //     return;
      //   }
      // }
      // console.log(formLabelAlign.extra.企业性质,'aaaa');
      // // console.log(formLabelAlign);
      // return
      if (this.platform("yali")) {
        if (formLabelAlign.gz == "危化品") {
          formLabelAlign.gz = "安全管理";
        }
        if (formLabelAlign.gz == "一般行业") {
          formLabelAlign.gz = "一般工贸";
        }
      }
      if (this.platform("dkaq") || this.platform("xcaq")) {
        if (formLabelAlign.gz == "高危安管") {
          formLabelAlign.gz = "安全管理";
        }
      }
      if (
        this.http.indexOf("bbxdf") != -1 ||
        this.http.indexOf("testtjy") != -1
      ) {
        if (this.formLabelAlign.extra.address == "") {
          return this.$toast.fail("所在地区不能为空");
        }
      }
      if (
        this.platformAnhui() &&
        formLabelAlign.gz != "一般工贸" &&
        !formLabelAlign.extra.企业性质
      ) {
        return this.$toast.fail("请选择企业性质");
      }
      if (
        this.platformAnhui() &&
        formLabelAlign.gz == "特种作业" &&
        !formLabelAlign.extra.注意事项
      ) {
        return this.$toast.fail("注意事项请签名");
      }
      formLabelAlign.extra = JSON.stringify(formLabelAlign.extra);
      // console.log(formLabelAlign);
      // return
      let setting = JSON.parse(this.init.setting);
      if (this.hutou) {
        formLabelAlign.hutou = this.hutou;
      }
      if (this.shuihao) {
        formLabelAlign.shuihao = this.shuihao;
      }
      if (this.openid) {
        formLabelAlign.openid = this.openid;
      }
      if (this.codeChk) {
        formLabelAlign.codeChk = this.codeChk;
      }
      if (this.platform("bosheng") && formLabelAlign.gz == "燃气从业人员培训") {
        if (!formLabelAlign.dep) {
          return this.$toast.fail("请选择燃气主管部门");
        }
      }
      let IDCard =
        /^[1-9]\d{5}(17|18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9X]$/; //身份证号校验
      let phone = /^1[3456789]\d{9}$/; //手机号校验
      // return
      for (let i = 0; i < this.fromList.length; i++) {
        let items = this.fromList[i];

        if (
          items.field_id == "exam_type" ||
          items.field_type == "download" ||
          items.field_id == "extra"
        ) {
          continue;
        }
        if (
          Boolean(items.selected) &&
          !formLabelAlign[items.field_id] &&
          items.field_id != "cert" &&
          items.passShow
        ) {
          if (items.field_id == "id_card") {
            if (!formLabelAlign["id_card_photo"]) {
              this.$toast.fail("身份证人像面" + "不能为空");
              return;
            }
            if (!formLabelAlign["id_card_emblem"]) {
              this.$toast.fail("身份证国徽面" + "不能为空");
              return;
            }
            continue;
          }
          this.$toast.fail(items.label + "不能为空");
          return;
        }
        if (
          Boolean(items.selected) &&
          items.field_id == "cert" &&
          items.passShow
        ) {
          let obj = JSON.parse(formLabelAlign[items.field_id]);
          if (
            !formLabelAlign[items.field_id] ||
            formLabelAlign[items.field_id] == "[]"
          ) {
            this.$toast.fail(items.label + "不能为空");
            return;
          }
          let list = JSON.parse(items.options);
          for (let j = 0; j < list.length; j++) {
            if (!obj[list[j].label]) {
              this.$toast.fail(list[j].label + "不能为空");
              return;
            }
          }
        }
        if (
          items.field_id == "username" &&
          Boolean(items.selected) &&
          !IDCard.test(formLabelAlign.username)
        ) {
          this.$toast.fail("身份证不合法");
          return;
        }
        if (
          items.field_id == "phone" &&
          Boolean(items.selected) &&
          !phone.test(formLabelAlign.phone)
        ) {
          this.$toast.fail("手机号码不合法");
          return;
        }
        if (
          Boolean(items.selected) &&
          items.field_type == "datetimeRange" &&
          items.passShow
        ) {
          if (!formLabelAlign[items.field_id][0]) {
            return this.$toast.fail(items.label + "开始时间不能为空");
          }
          if (!formLabelAlign[items.field_id][1]) {
            return this.$toast.fail(items.label + "结束时间不能为空");
          }
        }
        if (items.field_type == "datetimeRange") {
          formLabelAlign[items.field_id] = JSON.stringify(
            formLabelAlign[items.field_id]
          );
        }
      }
      if (
        (this.platform("hzdpx") ||
          this.platform("xtaq") ||
          (this.platform("zcaq") && formLabelAlign.gz == "大培训")) &&
        !formLabelAlign.codeChk
      ) {
        return this.$toast.fail("请输入验证码");
      }
      const obj = getstartInfo() ? JSON.parse(getstartInfo()) : {};
      formLabelAlign.admin_user_id = obj.admin_user_id ? obj.admin_user_id : "";
      formLabelAlign.depid = obj.depid ? obj.depid : "";
      formLabelAlign.dep = obj.dep ? obj.dep : "";
      formLabelAlign.grade = obj.grade ? obj.grade : "";
      // if (this.platformAnhui()) {
      // }
      // return
      this.loading = true;
      applyAdd(formLabelAlign).then((res) => {
        if (getstartInfo()) {
          delstartInfo(); //删除之前的管理员信息
        }
        this.loading = false;
        if (res.code == 200) {
          if (setting.PCwxpay == "是") {
            // 判断是否有在线缴费的权限
            let msg =
              "请点击下方培训交费按钮进行交费，交费成功后即可开通培训权限进行学习";
            if (this.platform("bosheng")) {
              msg =
                "您已报名成功，该平台免费提供课程学习、题库练习、模拟考试、学习统计等服务功能，仅需支付平台运维费用";
            }
            if (Number(this.itemA.price)) {
              //判断该科目是否是在线缴费
              this.$dialog
                .confirm({
                  title: "提示",
                  message: msg,
                  confirmButtonText: "去交费",
                  beforeClose: (action, done) => {
                    if (action == "confirm") {
                      if (setting.payType == "H5") {
                        window.open(
                          this.http +
                            "/index/apply/mph5?applyid=" +
                            res.data.applyid
                        );
                        setapplyid(res.data.applyid);
                      } else {
                        setapplyid(res.data.applyid);
                        mpo({
                          applyid: res.data.applyid,
                          openid: this.openid,
                        }).then((resp) => {
                          if (resp.code == 200) {
                            WeixinJSBridge.invoke(
                              "getBrandWCPayRequest",
                              resp.data,
                              (res) => {
                                if (
                                  res.err_msg == "get_brand_wcpay_request:ok"
                                ) {
                                  this.$toast.success("支付成功");
                                  location.reload();
                                } else {
                                  delapplyid();
                                  this.$toast.fail("支付失败");
                                }
                              }
                            );
                          } else {
                            delapplyid();
                            this.$toast.fail(resp.msg);
                          }
                        });
                      }
                      done();
                    } else {
                      done();
                    }
                  },
                })
                .then(() => {
                  // this.$router.push('/')
                  // this.$toast.success('缴费成功')
                })
                .catch(() => {});
            } else {
              this.$dialog
                .confirm({
                  title: "提示",
                  message: "报名成功，管理员审核成功后即可开通培训权限",
                })
                .then(() => {
                  this.$router.push("/");
                })
                .catch(() => {});
            }
          } else {
            this.$dialog
              .confirm({
                title: "提示",
                message:
                  this.platform("hzdpx") ||
                  this.platform("xtaq") ||
                  (this.platform("zcaq") && formLabelAlign.gz == "大培训")
                    ? "报名成功,点击确定跳转至登陆界面"
                    : "报名成功，管理员审核成功后即可开通培训权限",
              })
              .then(() => {
                if (
                  this.platform("hzdpx") ||
                  this.platform("xtaq") ||
                  (this.platform("zcaq") && formLabelAlign.gz == "大培训")
                ) {
                  window.open(
                    this.http +
                      "/user/#/wxlogin?username=" +
                      formLabelAlign.username,
                    "_self"
                  );
                } else {
                  this.$router.push("/");
                }
              })
              .catch(() => {});
          }
        } else if (res.msg == "已经报过名了") {
          if (this.isJf && !this.platform("bosheng")) {
            // this.$refs.jf.open()
            let applyid = res.err.applyid;
            this.loading = true;
            getapplyInfor({
              username: formLabelAlign.username,
              subject_id: formLabelAlign.subject_id,
            }).then((res) => {
              if (res.code == 200) {
                if (res.data.length == 0) {
                  this.loading = false;
                  this.$dialog.confirm({
                    title: "提示",
                    message: "您已经报名并缴费，请到学员端登录学习",
                    confirmButtonText: "去登录",
                    cancelButtonText: "取消",
                    showClose: false,
                    beforeClose: (action, done) => {
                      if (action == "confirm") {
                        window.open(this.http + "/user", "_self");
                      }
                      done();
                    },
                  });
                } else {
                  this.loading = false;
                  this.$dialog.confirm({
                    title: "提示",
                    message: "该身份证号的该培训科目已报名未缴费，是否现在缴费",
                    confirmButtonText: "去缴费",
                    cancelButtonText: "取消",
                    showClose: false,
                    beforeClose: (action, done) => {
                      if (action == "confirm") {
                        this.$refs.jf.submit(formLabelAlign.username, applyid);
                      }
                      done();
                    },
                  });
                  return;
                }
              }
            });
          } else {
            this.$toast.fail(res.msg);
          }
        } else {
          this.$toast.fail(res.msg);
        }
      });
    },
    lazyLoad(node, resolve) {
      let id = node.data ? node.data.region_id : 0;
      regionList({ region_pid: id }).then((res) => {
        resolve(res.data.list);
      });
    },
    //确定
    // onConfirm(val) {
    //   this.formLabelAlign.gz = val;
    //   let str = val;
    //   if (this.platform("yali")) {
    //     if (val == "危化品") {
    //       str = "安全管理";
    //     }
    //     if (val == "一般行业") {
    //       str = "一般工贸";
    //     }
    //   }
    //   if (this.platform("dkaq")) {
    //     if (val == "高危安管") {
    //       str = "安全管理";
    //     }
    //   }
    //   this.showPicker = false;
    //   this.gzChange(str);
    // },
    //确定
    InputConfirm(val) {
      this.formLabelAlign[this.formLabelAlign.isShow] = val;
      this.showCascader = false;
      this.fromList.map((item) => {
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder = val;
        }
      });
    },
    //确定
    pickConfirm(val) {
      this.fromList.map((item) => {
        let date = new Date(val);
        let LYJC_TIME =
          date.getFullYear() +
          "-" +
          (date.getMonth() + 1) +
          "-" +
          date.getDate();
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder = LYJC_TIME;
        }
        switch (this.formLabelAlign.isShow) {
          case "学历结束时间":
            this.xueli_endtime = LYJC_TIME;
            break;
          case "学历开始时间":
            this.xueli_starttime = LYJC_TIME;
            break;
          case "工作开始时间":
            this.work_starttime = LYJC_TIME;

            break;
          case "工作结束时间":
            this.work_endtime = "至今";
            break;
          case "qzsj":
            this.formLabelAlign.qzsj = LYJC_TIME;
            break;
        }

        if (this.formLabelAlign.isShow == "学历结束时间") {
        } else {
        }

        if (item.label == "学习工作经历") {
          let date = new Date(val);
          if (this.formLabelAlign.isShow == "工作结束时间") {
          } else {
          }
        }
      });

      this.showCascader = false;
    },
    vanClick(root, time) {
      const obj = getstartInfo()
        ? JSON.parse(getstartInfo())
        : {
            grade: false,
          };
      if (
        window.sessionStorage.getItem("Homegz") &&
        obj.grade &&
        root.field_id == "gz"
      ) {
        return false;
      }

      const { field_type, field_id, options, label, placeholder } = root;
      this.formLabelAlign.isShow = field_id;

      if (
        field_type == "input" ||
        field_type == "number" ||
        field_type == "textarea"
      )
        return false;
      this.showAddress = true;
      // this.Cascadervalue=
      // return
      let list = [];
      try {
        list = options ? JSON.parse(options) : [];
      } catch {
        list = options ? options : [];
      }
      this.formLabelAlign.options = [];
      list.map((item) => {
        if (item.e) {
          this.formLabelAlign.options.push(item.e);
        } else {
          this.formLabelAlign.options.push(item);
        }
      });
      if (field_type == "select") {
        switch (field_id) {
          case "gz":
            this.columns = this.GZList;
            break;
          default:
            this.columns = this.formLabelAlign.options;
            break;
        }
      }
      if (field_id == "region_id") {
        this.Cascadervalue = this.formLabelAlign[field_id]
          ? this.formLabelAlign[field_id].split(",")[
              this.formLabelAlign[field_id].split(",").length - 1
            ]
          : "";
        regionList({ region_pid: 0 }).then((res) => {
          this.pakeHotl = res.data.list;
        });
      }
      this.$forceUpdate();
    },
    vanClickDate(root, sing, p) {
      const { field_type, field_id, options, label } = root;
      if (field_id == "history" && this.platform("lyjc") && sing == "end") {
        return;
      }
      if (field_type == "datetimeRange") {
        if (sing == "start") {
          this.showDatestart = true;
        } else {
          this.showDateend = true;
        }
      } else {
        this.showDate = true;
      }
      if (p && p.field_type == "json") {
        this.formLabelAlign.isShow = root.label;
      } else {
        this.formLabelAlign.isShow = field_id;
      }
      // if(sing!='json'){
      // }else{
      //   console.log(label,'666');
      //   this.formLabelAlign.isShow = label;
      // }
    },
    //联机选择
    onFinish({ selectedOptions }) {
      this.showAddress = false;
      // this.formLabelAlign[this.formLabelAlign.isShow] = selectedOptions.map((option) => option.title).join('/')
      // this.Cascadervalue = selectedOptions.map((option) => option.title).join('/')

      this.fromList.map((item) => {
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder = selectedOptions
            .map((option) => option.title)
            .join("/");
          // this.formLabelAlign[this.formLabelAlign.isShow] = selectedOptions.map((option) => option.id).join(',')
        }
      });
    },
    //工作地点
    HotFinish({ selectedOptions }) {
      this.showAddress = false;
      console.log(selectedOptions, "777");
      // this.formLabelAlign[this.formLabelAlign.isShow] = selectedOptions.map((option) => option.title).join('/')
      // this.Cascadervalue = selectedOptions.map((option) => option.title).join('/')
      this.fromList.map((item) => {
        if (item.field_id == this.formLabelAlign.isShow) {
          item.placeholder = selectedOptions
            .map((option) => option.region_name)
            .join("/");
          this.formLabelAlign[this.formLabelAlign.isShow] = selectedOptions
            .map((option) => option.region_id)
            .join(",");
          console.log(this.formLabelAlign[this.formLabelAlign.isShow], "9999");
        }
      });
      // console.log(this.formLabelAlign,'67890000');
    },
    //
    downloadImg2(data) {
      const { appendix } = data;
      appendix.map((item) => {
        downloadAll(item.src, item.name);
      });
      // if (this.formLabelAlign.gz == "特种作业") {
      //   window.open("https://dkaq.taijieyun.com/storage/userimage/dkaq/20221114/983a84f2eeccb07ac44bfdea89ee2571.doc");
      // }
      // if (this.formLabelAlign.gz == "一般工贸" || this.formLabelAlign.gz == "安全管理") {
      //   window.open("https://dkaq.taijieyun.com/storage/userimage/dkaq/20221114/6182ba9e60c9500b76c52c3f42fca0d9.doc");
      // }
      // if (this.platformAnhui() && this.platformAnhui().length != 0) {
      //   this.platformAnhui().forEach((item) => {
      //     if (item.gz.includes(this.formLabelAlign.gz) && item.name == name) {
      //       downloadAll(item.filePath, item.name);
      //     }
      //   });
      // }
      // if (this.platform("xinhua")) {
      //   window.open(
      //     "https://xinhua.taijieyun.com/storage/userimage/xinhua/20221227/0aeedb419f2afbb56415242c6dfd8505.docx"
      //   );
      // }
    },
    downloadImg3() {
      if (
        this.formLabelAlign.gz == "一般工贸" ||
        this.formLabelAlign.gz == "安全管理"
      ) {
        window.open(
          "https://dkaq.taijieyun.com/storage/userimage/dkaq/20221114/fdf8c2f000a3becdbf5ca52495aa44dd.docx"
        );
      }
    },
    //打开签名
    writeName(item, id) {
      const { field_id, label } = item;
      let name = field_id;

      // this.$refs.autograph.clear();
      if (name == "jkcns") {
        if (!this.formLabelAlign.nickname) {
          return this.$toast.fail("姓名不能为空");
        }
        if (!this.formLabelAlign.username) {
          return this.$toast.fail("身份证号不能为空");
        }
        if (!this.subjectTitle) {
          return this.$toast.fail("请选择培训科目后再签名");
        }
      }
      if (name == "education" && !this.formLabelAlign.education) {
        return this.$toast.fail("请选择学历后再签名");
      }
      this.openBookalert(item, label).then((res) => {
        if (res) {
          this.fileNameWirth = name;
          this.DOMID = id;
          this.dialogShow = true;
          // if(!this.formLabelAlign[this.fileNameWirth]){
          // }
          this.$nextTick(() => {
            this.$refs.autograph.clear();
            this.canvasdata = this.$refs.autograph.commit();
          });
        }
      });
    },
    //阿克苏提交签名
    submitAks(file) {
      if (file) {
        this.DOMID = "DomImgjkcns";
        let that = this;
        let reader = new FileReader();
        reader.readAsDataURL(file.raw);
        reader.onload = (e) => {
          console.log(e.target);
          this.autographPath = e.target.result;
          upFileqm(this.autographPath, this.formLabelAlign.nickname, {
            field: "signature",
          }).then((res) => {
            if (res.code == 200) {
              this.formLabelAlign.signature = res.data.url;
            }
          });
          setTimeout(() => {
            upFile(
              this.formLabelAlign.nickname + "jkcns",
              { field: "jkcns" },
              this.DOMID
            ).then((res) => {
              if (res.code == 200) {
                this.$message.success("提交成功");
                // this.autographPath = res.data.url
                this.formLabelAlign.jkcns = res.data.url;
                this.dialogShow = false;
              } else {
                this.$message.error("签名失败");
              }
            });
          }, 200);
        };
      }
    },
    //提交签名图片
    async submit(action, done) {
      // dialogShow = false
      // return new Promise((resolve) => {
      //     console.log(1111111)
      //
      // });
      if (action === "confirm") {
        if (this.canvasdata === this.$refs.autograph.commit()) {
          this.$toast.fail("请签名后提交");
          done(false);
        }
        this.autographPath = this.$refs.autograph.commit();
        // if (this.DOMID == "DomImgzjbl") {
        //   this.autographPath2 = this.$refs.autograph.commit();
        // } else if (this.DOMID == "DomImgXL") {
        //   this.autographPath3 = this.$refs.autograph.commit();
        // } else if (this.DOMID == "DomImgjkcns") {
        //   this.autographPath1 = this.$refs.autograph.commit();
        // }
        console.log(this.DOMID, this.formLabelAlign, "666");
        if (!this.DOMID) {
          // if(typeof this.formLabelAlign.extra != 'object'){
          //   this.formLabelAlign.extra = {}
          // }
          this.formLabelAlign.extra[this.fileNameWirth] =
            this.$refs.autograph.commit();
        } else {
          // this.formLabelAlign[this.fileNameWirth] = this.$refs.autograph.commit();
        }

        // if (!this.DOMID) {
        //   if(this.fileNameWirth=='注意事项'){
        //     this.autographPath4 = this.$refs.autograph.commit(); //注意事项
        //   }
        //   if(this.fileNameWirth=='cxsm'){
        //     this.autographPath5 = this.$refs.autograph.commit(); //注意事项
        //   }else
        //   if(this.fileNameWirth=='cnsx'){
        //     this.autographPath6 = this.$refs.autograph.commit(); //注意事项
        //   }else
        //   if(this.fileNameWirth=='zqtys'){
        //     this.autographPath7 = this.$refs.autograph.commit(); //注意事项
        //   }
        //   else if(this.fileNameWirth=='cnx'){
        //     this.autographPath8 = this.$refs.autograph.commit(); //注意事项
        //   }
        // }
        let field_type = "sign";
        this.fromList.map((item) => {
          if (item.field_id == this.fileNameWirth) {
            field_type = item.field_type;
          }
        });
        await upFileqm(this.autographPath, this.formLabelAlign.nickname, {
          field: "signature",
        }).then((res) => {
          if (res.code == 200) {
            this.formLabelAlign.signature = res.data.url;
            if (!this.DOMID) {
              this.formLabelAlign.extra[this.fileNameWirth] = res.data.url;
            }
            this.formLabelAlign[this.fileNameWirth] = res.data.url;
            this.$forceUpdate();
            done();
            // if (this.platformAnhui()) {
            //   this.formLabelAlign.extra[this.fileNameWirth] = res.data.url;
            //   if(this.DOMID){
            //   }
            //   this.$toast.success("提交成功");
            //   done();
            // }
            // if(this.fileNameWirth=='cxsm'||this.fileNameWirth=='cnsx'||this.fileNameWirth=='zqtys'||this.fileNameWirth=='cnx'){
            //   this.formLabelAlign.extra[this.fileNameWirth] = res.data.url;
            //   this.$toast.success("提交成功");
            //   done();
            // }
          } else {
            this.$toast.fail(res.msg || "签名储存失败，请联系管理员");
          }
        });
        if (field_type != "sign") {
          setTimeout(() => {
            upFile(
              this.formLabelAlign.nickname + this.fileNameWirth,
              { field: this.fileNameWirth },
              this.DOMID
            )
              .then((res) => {
                if (res.code == 200) {
                  this.$toast.success("提交签名成功");
                  this.formLabelAlign[this.fileNameWirth] = res.data.url;
                  done();
                } else {
                  this.$toast.fail(res.msg || "签名失败");
                }
              })
              .catch((err) => {
                this.$toast.fail("存储状态异常,请重试!");
                done();
              });
          }, 500);
        }
      } else {
        done();
      }
    },
    //通用弹出提醒
    openBookalert(data, title) {
      let text = data.field_id;
      //  this.DomImgShow=true  formLabelAlign
      if (!this.subjectTitle && text == "cxsm") {
        return this.$message.error("请选择培训科目不能为空");
      }
      var msg = "";
      if (text == "cxsm") {
        msg = `本人符合(${this.subjectTitle})人员考试条件，在表中填写的个人信息和提供的身份证明等内容是真实的(本人提供的身份证明等内容由培训机构留存)`;
      }
      if (text == "cnsx") {
        msg = `1.本人身体健康，无妨碍从事相应特种作业的器质性心脏病、癫痫病、美尼尔氏症、
                眩晕症、癔病、震颤麻痹症、精神病、痴呆症以及其他疾病和生理缺陷；2.以上所填写的
                本人信息及提供的身份证复印件、学历证书复印件等材料真实有效；3.本人按《特种作业
                人员安全技术培训考核管理规定》（国家安全监管总局令第30号）有关规定参加相应的
                安全技术理论培训和实际操作培训4.以上个人信息和承诺事项以及提供的有关材料，如
                有弄虚作假或欺骗等行为，自愿被依法撤销《中华人民共和国特种作业操作证》，3年内
                不再申请办证。`;
      }
      if (text == "sqbqm" && this.formLabelAlign.gz == "特种作业") {
        msg =
          "本人符合《特种作业人员安全技术培训考核管理规定》(国家安全监管总局令第30号)第四条 规定的条件，并按规定参加相应的安全技术理论培训和实际操作培训。";
      }
      if (text == "sqbqm" && this.formLabelAlign.gz == "安全管理") {
        msg =
          "本人符合《生产经营单位安全培训规定》(国家安全监管总局令第3号)有关 规定参加相应的安全培训。";
      }
      if (text == "jkcns") {
        msg =
          "本人身体健康，无妨碍从事相应特种作业的器质性心脏病、癫痫病、美尼尔氏症、眩晕症、癔病、震颤麻痹症、精神病、痴呆症以及其他疾病和生理缺陷。本人对以上信息的真实性负责，如有隐瞒，相关责任全部由本人承担。";
      }
      if (text == "edu_photo") {
        if (!this.formLabelAlign.education) {
          return this.$toast.fail("请选择您的学历!");
        }
        msg = `我承诺：本人具有${this.formLabelAlign.education}学历，以上内容真实有效，如有虚假，本人愿意承担相应责任`;
      }
      if (text == "注意事项" && this.platform("dkaq")) {
        msg =
          "1.报名成功后，一个月以内，扣费100元！（包含视频学习卡，材料费，照片费，人工服务费）一个月以后或参加过培训一律不退费！ 2.理论实操各二次机会，二次不合格，重新报名！ 3.报名开始计算一年内有效，一年内不考，重新报名！（如遇不可抗拒因素，适当延期） 4.报考学员，必须完成各工种培训大纲学时，理论线上视频课程，不完成一律不安排考试，实操线下培训，必须参加。如遇缺课，漏签，代签，不完成一律不安排考试，培训结束后，会收到短信通知，学员自行缴纳考试费，初训（理论考试费50元，实操考试费110元），复训（理论考试费50元）学员延迟缴费，出现上诉以上问题，不能考试，学员自行承担后果！ 5.本校只提供开局培训费发票，考试费发票学员自行打印，（考试费需要报销学员，考试注册时候一定要填写正确的企业名称） 6. 一般工贸和危化经营生产主要负责人，管理员不用缴纳考试费  7.报考人员年龄限制18岁-60岁";
      }
      if (text == "注意事项" && this.platform("xcaq")) {
        msg =
          "1.报名成功后，一周以内，扣费100元！（包含视频学习卡，材料费，照片费，人工服务费）一周以后一律不退费！ 2.理论实操各二次机会，二次不合格，重新报名！ 3.报名开始计算一年内有效，一年内不考，重新报名！（如遇不可抗拒因素，适当延期） 4.报考学员，必须完成各工种培训大纲学时，理论线上视频课程，不完成一律不安排考试，实操线下培训，必须参加。如遇缺课，漏签，代签，不完成一律不安排考试，培训结束后，会收到短信通知，学员自行缴纳考试费，初训（理论考试费50元，实操考试费110元），复训（理论考试费50元）学员延迟缴费，出现上诉以上问题，不能考试，学员自行承担后果！ 5.本校只提供开局培训费发票，考试费发票学员自行打印，（考试费需要报销学员，考试注册时候一定要填写正确的企业名称） 6. 一般工贸和危化经营生产主要负责人，管理员不用缴纳考试费  7.报考人员年龄限制18岁-60岁";
      }
      if (text == "cnx") {
        msg = `本人承诺，以上填写的个人信息和提供的身份证复印件、学历证书复印件及个人健康承诺书内容真实。`;
      }
      if (this.platform("kaiqi") && text == "zqtys") {
        // ImagePreview([
        //   require("../../components/img/kaiqi/1.png"),
        //   require("../../components/img/kaiqi/2.png"),
        // ]);
        return new Promise((resolve) => {
          ImagePreview({
            images: [
              require("../../components/img/kaiqi/1.png"),
              require("../../components/img/kaiqi/2.png"),
            ],
            onClose() {
              resolve(true);
            },
          });
        });
      }
      if (
        (this.platform("dlgd") ||
          this.platform("dlld") ||
          this.platform("yjq") ||
          this.platform("dlxh") ||
          this.platform("mkah")) &&
        text == "CNBook"
      ) {
        return new Promise((resolve) => {
          ImagePreview({
            images: [require("../../components/img/dlld/cnbook.png")],
            onClose() {
              resolve(true);
            },
          });
        });
      }
      if (this.platform("mingda") && text == "zqtys") {
        // ImagePreview([require("../../components/img/mingda/1.png")]);
        return new Promise((resolve) => {
          ImagePreview({
            images: [require("../../components/img/mingda/1.png")],
            onClose() {
              resolve(true);
            },
          });
        });
      }
      if (this.platform("ddrc") && text == "zqtys") {
        return new Promise((resolve) => {
          ImagePreview({
            images: [
              require("../../components/img/ddrc/1.png"),
              require("../../components/img/ddrc/2.png"),
            ],
            onClose() {
              resolve(true);
            },
          });
        });
      }
      if (text == "fwxy") {
        return new Promise((resolve) => {
          ImagePreview({
            images: [
              "https://lyky.taijieyun.com/storage/userimage/lyky/20230523/35e1f152e87a67bac254642ef3eebd2c.png",
            ],
            onClose() {
              resolve(true);
            },
          });
        });
      }
      if (data.options) {
        msg = data.options;
      }
      let ret = false;
      return new Promise((resolve) => {
        this.$dialog
          .alert({
            title: title,
            message: msg,
          })
          .then(() => {
            resolve(true);
          })
          .catch(() => {
            resolve(false);
          });
      });
    },
    //打开承诺书
    openBook() {
      this.$dialog
        .alert({
          title: "健康承诺书",
          message:
            "本人身体健康，无妨碍从事相应特种作业的器质性心脏病、癫痫病、美尼尔氏症、眩晕症、癔病、震颤麻痹症、精神病、痴呆症以及其他疾病和生理缺陷。本人对以上信息的真实性负责，如有隐瞒，相关责任全部由本人承担。",
        })
        .then(() => {});
    },
    //注意事项
    openBookshixiang() {
      this.$dialog
        .alert({
          title: "注意事项",
          message:
            "1.报名成功后，一个月以内，扣费100元！（包含视频学习卡，材料费，照片费，人工服务费）一个月以后一律不退费！ 2.理论实操各二次机会，二次不合格，重新报名！ 3.报名开始计算一年内有效，一年内不考，重新报名！（如遇不可抗拒因素，适当延期） 4.报考学员，必须完成各工种培训大纲学时，理论线上视频课程，不完成一律不安排考试，实操线下培训，必须参加。如遇缺课，漏签，代签，不完成一律不安排考试，培训结束后，会收到短信通知，学员自行缴纳考试费，初训（理论考试费50元，实操考试费110元），复训（理论考试费50元）学员延迟缴费，出现上诉以上问题，不能考试，学员自行承担后果！ 5.本校只提供开局培训费发票，考试费发票学员自行打印，（考试费需要报销学员，考试注册时候一定要填写正确的企业名称） 6. 一般工贸和危化经营生产主要负责人，管理员不用缴纳考试费  7.报考人员年龄限制18岁-60岁",
        })
        .then(() => {});
    },
    //证件办理费用协议
    openBookXY() {
      //  this.DomImgShow=true
      this.$dialog
        .alert({
          title: "证件办理费用协议",
          message:
            "一、甲方依据相关规定收取乙方培训、考试、办理及发放证件等费用，并依法对乙方提供相关服务。二、乙方必须按甲方规定时间进行培训、考试及取证，因乙方个人原因及行为不能按时参加培训、考试及无法取证者，甲方不予退费。三、从报名开始，六个月之内必须考完，否则视为自动放弃。四、代办人员需将本协议告知学员本人。",
        })
        .then(() => {});
    },
    //打开学历承诺书  education
    openBookXl() {
      if (!this.formLabelAlign.education) {
        return this.$toast.fail("请选择您的学历!");
      }
      this.$dialog
        .alert({
          title: "学历承诺书",
          message: `我承诺：本人具有${this.formLabelAlign.education}学历，以上内容真实有效，如有虚假，本人愿意承担相应责任`,
        })
        .then(() => {});
    },
    //示例图片
    openDefimg(path) {
      this.$dialog
        .alert({
          title: "示例图片",
          message: `<div style="display: flex;justify-content: center;align-items: center;background:#eee;"><img src="${path[0].src}" style="height:313px;width:206.5px;" alt="示例图片"></div>`,
          allowHtml: true,
        })
        .then(() => {});
    },
    //下载学历承诺书
    downReader() {
      let MicroMessenger = navigator.userAgent.match(/MicroMessenger/i);
      if (MicroMessenger) {
        this.TCshow = true;
        this.downloadURL =
          "https://lyky.taijieyun.com/template/lyky/%E5%AD%A6%E5%8E%86%E6%89%BF%E8%AF%BA%E4%B9%A6.docx";
      } else {
        download(
          "https://lyky.taijieyun.com/template/lyky/%E5%AD%A6%E5%8E%86%E6%89%BF%E8%AF%BA%E4%B9%A6.docx",
          "学历承诺书.docx"
        );
      }
    },
    //下载附件
    downFuled(files) {
      let MicroMessenger = navigator.userAgent.match(/MicroMessenger/i);
      files.map((item) => {
        if (MicroMessenger) {
          // this.TCshow = true;
          // this.downloadURL = item.src;
          download(item.src + "?mp.wexin.qq.com", item.name);
        } else {
          download(item.src, item.name);
        }
      });
      // window.open('https://lyky.taijieyun.com/template/lyky/%E4%BD%93%E6%A3%80%E8%A1%A8.doc')
      // download('https://lyky.taijieyun.com/template/lyky/%E4%BD%93%E6%A3%80%E8%A1%A8.doc','健康查体表.doc')
    },
    copy() {
      let url = this.downloadURL;
      let oInput = document.createElement("input");
      oInput.value = url;
      document.body.appendChild(oInput);
      oInput.select(); // 选择对象;
      document.execCommand("Copy"); // 执行浏览器复制命令
      this.$toast.success("复制成功");
      oInput.remove();
    },
    //太化 提交
    commitA() {
      if (this.$refs.taihua.commit()) {
        let objA = this.$refs.taihua.commit()[0];
        let objB = this.$refs.taihua.commit()[1];
        this.loading = true;
        applyAdd({ ...objA, extra: JSON.stringify(objB) }).then((res) => {
          this.loading = false;
          if (res.code == 200) {
            this.$confirm(
              "报名成功，管理员审核成功后即可开通培训权限",
              "提示",
              {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "success",
                showClose: false,
              }
            )
              .then(() => {
                this.$router.push("/");
              })
              .catch(() => {});
          } else {
            this.$message.error(res.msg);
          }
        });
      }
    },

    //打开相机
    openCorme(item) {
      if (origin.indexOf("https") === -1) {
        this.$dialog
          .alert({
            title: "提示",
            message:
              "您使用的功能需用https协议地址进行访问：<br/>如需继续访问请点击 “跳转” 按钮，继续报名；<br/>如要返回，请点击“取消”。",
            confirmButtonText: "跳转",
            cancelButtonText: "取消",
            messageAlign: "left",
            width: "350px",
            showCancelButton: true,
          })
          .then(() => {
            location.href = "https" + location.href.split("http")[1];
          });
        return;
      }
      this.setOptions = {
        style: {},
        clip: 0.9,
        msgs: [
          "1. 请拍摄或在相册中选择证件图片",
          "2. 证件信息必须无遮挡且清晰不模糊。",
          "3. 照片请勿上下、左右倒置或翻转；",
        ],
        field_id: item.field_id,
      };
      if (item.field_id == "photo") {
        // =0.75
        // delete this.setOptions.clip
        // this.setOptions.style = {
        //   width: 375,
        //   height: 480,
        // };
        this.setOptions.clip = 1.28;
        this.setOptions.field_id = item.field_id;
        this.setOptions.defImg =
          item.others && item.others.defImg[0] ? item.others.defImg[0] : null;
      }
      if (item.field_id == "id_card_photo") {
        this.setOptions = {
          style: {},
          clip: 0.63,
          field_id: item.field_id,
          msgs: [
            "1. 请拍摄或在相册中选择证件图片",
            "2. 证件信息必须无遮挡且清晰不模糊。",
            "3. 照片请勿上下、左右倒置或翻转；",
          ],
        };
      }
      if (item.field_id == "id_card_emblem") {
        this.setOptions = {
          style: {},
          clip: 0.63,
          field_id: item.field_id,
          msgs: [
            "1. 请拍摄或在相册中选择证件图片",
            "2. 证件信息必须无遮挡且清晰不模糊。",
            "3. 照片请勿上下、左右倒置或翻转；",
          ],
        };
      }
      if (
        item.field_id == "edu_photo" ||
        item.field_id == "hukou_photo" ||
        item.field_id == "yyzz" ||
        item.field_id == "zyzgz" ||
        item.field_id == "healthy_img" ||
        item.field_id == "trip_img" ||
        item.field_id == "test_img" ||
        item.field_id == "training_record"
      ) {
        this.setOptions = {
          style: {},
          clip: 0.75,
          field_id: item.field_id,
          msgs: [
            "1. 请拍摄或在相册中选择证件图片",
            "2. 证件信息必须无遮挡且清晰不模糊。",
            "3. 照片请勿上下、左右倒置或翻转；",
          ],
        };
      }
      this.showcamera = true;
    },

    //拍照图片储存
    imgurl({ url, field_id }) {
      //url   64
      let file = dataURLtoFile(url);
      // console.log(file);  id_card_photo
      if (this.$refs["img" + field_id] && this.$refs["img" + field_id][0]) {
        upFileqm(url, "1", {
          field: field_id,
        }).then((res) => {
          if (res.code == 200) {
            this.fromList.map((item) => {
              if (item.field_id == field_id) {
                item.fileList = [
                  {
                    url: url,
                    name: "1",
                  },
                ];
              }
              if (field_id == "id_card_photo") {
                item.id_card_photo = [
                  {
                    url: url,
                    name: "1",
                  },
                ];
              }
              if (field_id == "id_card_emblem") {
                item.id_card_emblem = [
                  {
                    url: url,
                    name: "1",
                  },
                ];
              }
              this.$forceUpdate();
            });
            // console.log(this.fromList);
            this.formLabelAlign[res.data.field] = res.data.url;
            // window.open(res.data.url)
            if (res.data.field == "last_cert") {
              this.formLabelAlign[res.data.field] = JSON.stringify([
                res.data.url,
              ]);
            }
            this.$forceUpdate();
            this.$toast.success("提交成功");
          }
        });
        // this.$refs['imgid_card_photo'][0].uploadImg(file);
      }
      if (field_id == "id_card_photo" && this.photoApply) {
        this.loading = true;
        const formData = new FormData();
        formData.append("image", file);
        aliasOCR(formData).then((res) => {
          this.loading = false;
          if (res.code == 200) {
            // this.$emit('info', res.data)
            let data = JSON.parse(res.data.body.Data).data.face.data;
            this.Arrpass.map((item) => {
              if (item.field_id == "username") {
                item.placeholder = data.idNumber; //身份证号
                this.formLabelAlign["username"] = data.idNumber;
                this.formLabelAlign.isShow = "username";
              }
              if (item.field_id == "nickname") {
                item.placeholder = data.name; //名字
                this.formLabelAlign["nickname"] = data.name;
                this.formLabelAlign.isShow = "nickname";
              }
              if (item.field_id == "gender") {
                item.placeholder = data.sex; //性别
                this.formLabelAlign["gender"] = data.sex;
                this.formLabelAlign.isShow = "gender";
              }
              // if (item.field_id == 'username') {
              //   item.placeholder = data.num //身份证号
              // }
            });
            this.$toast.success(res.msg);
          } else {
            this.$toast.fail("图片格式不支持或图片内容不是身份证");
            this.remove(field_id);
            // this.$emit('error', res.data)
          }
        });
      }
    },
    //获取识别图片
    chengePhoto(data) {},
    //图片背景色更改
    PictureEditBack(item, file) {
      this.showProBack = true;
      this.backPhoto = file.url;
    },
    //修改背景图片
    checkBackGround(col) {
      let setting = JSON.parse(this.init.setting);
      this.showProBackLoading = true;
      if (setting.backgroundPhoto == "高级") {
        photoMake({
          url: this.formLabelAlign.photo,
          bk: "#ffffff",
          spec: 1, //一寸 1 二寸 4
        }).then((res) => {
          this.showProBackLoading = false;
          if (res.code == 200) {
            this.backPhoto = res.data.result;
            let url = res.data.result;
            if (process.env.NODE_ENV === "development") {
              url =
                "/photoMake" +
                res.data.result.split("https://oapi.aisegment.com")[1];
            } else {
              url = res.data.result;
            }
            fetch(url, {
              mode: "no-cors",
            })
              .then((res) => {
                return res.blob();
              })
              .then((blob) => {
                this.backPhotoFile = new File([blob], "photo.png", {
                  type: "image/jpeg",
                });
                console.log(this.backPhotoFile);
              })
              .catch((err) => {});
          }
        });
      } else {
        axios("/taof", "get", {
          url: this.formLabelAlign.photo,
          col,
        }).then((res) => {
          this.showProBackLoading = false;
          if (res.data.code == 200) {
            this.backPhoto = res.data.url;
            let url = res.data.url;
            if (process.env.NODE_ENV === "development") {
              url = "/urlapi" + res.data.url.split("https://cache.wer.plus")[1];
            } else {
              url = res.data.url;
            }
            fetch(url, {
              mode: "no-cors",
            })
              .then((res) => {
                return res.blob();
              })
              .then((blob) => {
                this.backPhotoFile = new File([blob], "photo.png", {
                  type: "image/jpeg",
                });
              })
              .catch((err) => {});
          } else {
            this.$message.error(res.data.msg);
          }
        });
      }
    },
    commitEditPhtot() {
      this.showProBack = false;
      if (this.$refs["imgphoto"][0]) {
        this.$refs["imgphoto"][0].uploadImg(this.backPhotoFile);
      } else {
        this.$refs["imgphoto"].uploadImg(this.backPhotoFile);
      }
      this.fromList.map((item) => {
        if (item.field_id == "photo") {
          item.fileList = [
            {
              url: this.backPhoto,
              name: "",
            },
          ];
        }
      });
    },
  },
  mounted() {
    this.$nextTick(() => {
      upFile("123", { field: "fwxy" }, "DomImgfwxy").then((res) => {
        console.log(res.data.url);
      });
    });
  },
};
</script>

<style lang="scss" scoped>
.applyHeade {
  height: 44px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  padding: 0 12px;
  color: #000;
  font-size: 1rem;
  margin-bottom: 10px;

  .back {
    display: flex;
    align-items: center;
    font-size: 1rem;
    color: #000;

    i {
      font-size: 1rem;
      // font-weight: 600;
    }
  }

  .button {
    // font-size: 1rem;
    padding: 10px;
    background: #166aff;
    border: #166aff;
    border-radius: 4px;
  }
}

.applyConter {
  height: calc(100vh - 54px);
  overflow-y: auto;
  overflow-x: hidden;
  background-color: #fff;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;

  .button {
    // font-size: 1rem;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    // padding: 10px;
    background: #166aff;
    border: #166aff;
    border-radius: 4px;
  }
}
</style>
<style lang="scss">
.crop-component .crop-around:after {
  background: none !important;
  content: "旋转" !important;
  width: 30px !important;
  height: 20px !important;
  color: #fff !important;
}

.crop-component .crop-close:after {
  background: none !important;
  content: "关闭" !important;
  width: 30px !important;
  height: 20px !important;
  color: #fff !important;
}

.crop-component .crop-reset:after {
  background: none !important;
  content: "重置" !important;
  width: 30px !important;
  height: 20px !important;
  color: #fff !important;
}

.crop-component .crop-btn:after {
  background: none !important;
  content: "提交" !important;
  width: 30px !important;
  height: 20px !important;
  color: #fff !important;
}
</style>
<style lang="scss" scoped>
.root {
  position: relative;
  overflow: hidden;
  background: #eee;
}

::v-deep {
  .el-form-item__content {
    line-height: 16px !important;
    margin-left: 0 !important;
  }

  .lablesClass {
    width: 100%;
    font-size: 1rem;
  }

  .van-picker__toolbar {
    button {
      font-size: 16px !important;
    }
  }

  .van-picker-column {
    font-size: 18px;
    // li{
    //   height: 50px !important;
    // }
  }

  .van-picker-column__item--selected {
    background-color: #f5f5f5;
  }

  .van-cascader__header {
    h2 {
      margin: 0 !important;
    }
  }

  .van-tabs {
    height: calc(100% - 48px);

    .van-tabs__content {
      height: calc(100% - 48px);

      .van-tab__pane {
        height: 100%;
      }
    }
  }

  .van-tab {
    font-size: 16px;
  }

  .van-cascader__options {
    height: calc(100%);
  }

  .van-cascader__option {
    font-size: 18px;
    padding: 14px 16px;
  }

  .vant {
    font-size: 1rem !important;

    &::after {
      position: absolute;
      box-sizing: border-box;
      content: " ";
      pointer-events: none;
      right: 16px;
      bottom: 0;
      left: 16px;
      border-bottom: 1px solid #ccc;
      -webkit-transform: scaleY(0.5);
      transform: scaleY(0.5);
    }
  }

  .van-cell {
    font-size: 1rem !important;
    display: flex;
    flex-direction: column;
    position: relative;

    &::after {
      // position: absolute;
      // box-sizing: border-box;
      // content: " ";
      // pointer-events: none;
      // right: 16px;
      // bottom: 0;
      // left: 16px;
      // border-bottom: 1px solid #ccc;
      // -webkit-transform: scaleY(0.5);
      // transform: scaleY(0.5);
      height: 0;
    }

    .van-cell__value {
      margin-top: 8px;
      padding: 8px 12px;
      background: #f5f5f5;
    }

    .van-icon {
      position: absolute;
      right: 30px;
      bottom: 18px;
      transform: rotate(90deg);
      // display: none;
    }
  }

  .el-form-item__label {
    font-size: 1rem !important;
  }

  .el-form-item {
    margin-bottom: 0px;
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
  }

  .catie {
    .van-cell__value {
      margin-top: 30px !important;
    }

    .van-cell {
      .van-icon {
        margin-top: 30px !important;
      }
    }
  }

  .tipTextarea {
    textarea {
      border: none !important;
    }
  }
}

.DomImg {
  position: absolute;
  z-index: -100;
  top: 0;
  left: 0;
  .A4page {
    width: calc(595px * 2);
    height: calc(840px * 2);
    // background:url('~@/assets/logo/pdfbg.png') no-repeat;
    overflow: hidden;
    -webkit-print-color-adjust: exact;
    color: #000;
    position: relative;
    padding: 70px 70px;

    u {
      // text-decoration:underline;
      border-bottom: 1px solid #333;
      // display: inline-block;
      // padding:0 80px;
    }

    p {
      margin: 0;
      font-size: 30px;
      line-height: 80px;
    }

    h1 {
      text-align: center;
      // font-weight: 600;
      font-size: 40px;
    }
  }
}

#DomImgzjbl {
  top: 0;

  // z-index: 5;
  .A4page {
    padding: 50px 150px;

    p {
      line-height: 60px;
    }
  }
}
</style>